• Resolved ronnicholls

    (@ronnicholls)


    Trying to create a local test version of production website. Exported prodction database and imported to localhost mySql using MAMP. Installed wordpress to htdocs and if I create a new database during install, it works fine. But when I copy over production WP subdirectories and change wp-config.php to point to the ‘imported’ database, I get UNABLE TO CONNECT. Any pointers to what I am missing would be gratefuly received

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator threadi

    (@threadi)

    Have you also adjusted the prefix in wp-config.php accordingly?

    Thread Starter ronnicholls

    (@ronnicholls)

    $table_prefix = ‘wp_’;

    Thanks for response. This is how it is in production config. It is also how it is in dummy wordpress install on localhost so I left it alone. Seems that it just doesn’t want to recognise my imported database. I am using root/root as user credentials as production creds don’t work anyway

    Moderator threadi

    (@threadi)

    If it is not, it is the access data to the database that is wrong. Double check them.

    Thread Starter ronnicholls

    (@ronnicholls)

    root has global prieveledges on all databases but I agree that this seems to be the issue . . . . .

    Do you have to perform a WP install for a new database? I was rather thinking that you could just use your production directories (and change wp-config). I ask this becasue if I do perform a WP install, it creates a database as part of the install (with nothing in it so to speak).

    Moderator threadi

    (@threadi)

    No, that is not necessary. The database must be accessible. If I have something like that, I try to log in via console with the stored access data. Then I can usually see the reason (e.g. missing access rights, wrong password, wrong port, firewall …). Nowadays, root access is usually not possible even with MySQL, so this could well be a reason.

    Thread Starter ronnicholls

    (@ronnicholls)

    Thanks. Will give it a go tomorrow

    Thread Starter ronnicholls

    (@ronnicholls)

    From another forum, I found that by adding the following to the foot of wp-config, that I now get a connection, but it is not formatted. More of an outline. Also I get 404 error when trying to access wp-admin ????

    What WP subdirectories should I keep from production site, and which from a clean WP install (if any). I think this is what I am struggling with

    /** Sets up WordPress vars and included files. */ define(‘WP_CACHE’, true); $currenthost = $_SERVER[‘HTTP_HOST’]; $mypos = strpos($currenthost, ‘localhost’); if ($mypos === false) { define(‘WP_HOME’,’http://YOURSITE.com’); define(‘WP_SITEURL’,’http://YOURSITE.com’); } else { define(‘WP_HOME’,’http://localhost:8888′); define(‘WP_SITEURL’,’http://localhost:8888′); }

    Thread Starter ronnicholls

    (@ronnicholls)

    All sorted. Needed to put the wordpress directory in the statements for WP_HOME and WP_SITEURL e.g.

    define(‘WP_HOME’,’http://localhost:8888/YourProjectDirectory’);

    Thanks @threadi for responding, and giving me the inspiration to continue debugging. Was getting close to jacking it in.

    Thread Starter ronnicholls

    (@ronnicholls)

    Resolved

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Unable to Connect to database’ is closed to new replies.