One thing that’s weird is even though i deleted wp-config.php and create a new default file by use the copy command, the error still appeared.
cp wp-config-sample.php wp-config.php
What happend?
Did you edit the wp.config.php
file and enter the new databases connection details in it? That error message means that you have got an incorrect value in one or more of the database fields and that’s not allowing you to connect to the database server.
Actually i used mysqldump to backup and move the old mysql database and then on the new server, i created a new database with new user and new password to restore in that.After that, i edited the wp-config.php file with new value and access the wordpress page at the new server’s address.That’s it.
And i’m sure the database was OK, not broken because the content of WordPress site on old server-side is still OK.
Sorry but i just moved mysql database, not html content of the old site. Could i restore the new wordpress site with just old mysql database?
You can, but my answer is the same as before. One or more of the details (hostname, database name, usernmae, password) is not correct in your sites wp-config.php
file, and that’s what’s causing that error.
If you are 100% sure that it’s all correct check with your hosting company and see if they can help. Sometimes you need to specify an actual hostnema or IP address as localhost
won’t work. Someitmes the MySQL port number changes. There’s a couple of other things that come into play, but they would all be ocntrolled by the server and the network.
Mysql port number? I didn’t know about that. Because i just focus on to username, database and password. Btw, i found that when i created the new database with exact same name as the old database , it worked.