Hi all,

This is probably a very simple question for most of you... I have been following the directions on here for 'copy your live site to a test site' as I want to eventually do an upgrade to Drupal 5.7 (currently 5.3)

I was doing great until I tried to change the settings.php folder based on these instructions:

" * $db_url = mysql://user:pass@localhost/test_site_db';

(test-site database login & password, URL location of the test-site database. "localhost" usually works by default.)"

In my copied 'settings' file my user name was the database name and the password looked like some sort of encrypted string of characters. Sooo I originally just changed the database name in that string to my new/test database but that just got me a "unable to connect to database" error.

I know the problem is just the user ID and password but I'm not sure how to set it in the new/copied database or how to express it in the settings file.

Any thoughts? I'm pretty clueless when it comes to working with databases, or user id's and passwords where databases are concerned but I've been managing the basics in myphpadmin so far.

Thanks folks!

Comments

jimbop’s picture

Your local machine setting line should look something like this:

$db_url = 'mysql://root:@localhost/dbname'; // offline mirror

where root is the username, there is no password, and the name of the database is dbname. On a shared host it will probably look something like:

$db_url = 'mysql://dbname:password@localhost/dbname'; // live site

If you are on a shared host your provider will have sent you your database name and password, else check the my.cnf file in root which often contains these details. If you have your own server you should have root access and be able to define these yourself.

jburnard’s picture

Hi jimbop,

I'm using a host and I exported the database from my live site and exported it to a new location on my host.

But based on this example:
$db_url = mysql://user:pass@localhost/test_site_db';

Where is says user in my live sites settings.php it was set as the database name. Then after the : is a number that looks like this "54dtcl4[I[Yu" so I'm assuming it's an encrypted password? Then it says @localhost/databasename

So I'm confused, I would obviously change the last part to the newly copied database name but would the username and password before the @ be the same before?

I tried that just now and I got:
"Unable to select database - We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database"

jburnard’s picture

Hi again, got it working. What I did was use my cPanel to create another user and password for the new database, then plug those into my settings.php file. It worked fine. Not sure why the existing one didn't work but all is well. Thanks for your help.

jburnard’s picture

SPOKE TO SOON ;(

I now get the front page to show up for the site using the new database but when I go to login to the drupal site I get:

Not Found
The requested URL /testcap/node was not found on this server.

It seems as all links point to where they would in the original site which makes sense but if that's the case how do you work around that when you copy your live site to a test site?

I was hoping that the new site would work just like the old but I can't even get in.... Please help :(