First, the discovery of problems
When I tried to edit the WordPress theme of the blog site, I suddenly found that the blog site could not connect, and then prompted the error "Establish database connection error" after refreshing. The natural idea is that MySQL may be wrong, so they landed on the VPS host, trying to start the MySQL service, but prompted failed.
Ii. Solutions
1. Open /var/log/mysql/error.log
the file and view the error log. When I read the log, I found that the first error message was:[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2, try to execute mysql_upgrade
still prompt error:
Looking for ' MySQL ' as:mysql
looking for ' Mysqlcheck ' As:mysqlcheck
error:failed while fetching Server version! Could is due to unauthorized access.
FATAL Error:upgrade failed
3, so, in search of similar problems on the Internet, found a solution. Enter the command: mysql_install_db --user=mysql --ldata=/var/lib/mysql
after it is installed automatically system tables
, it can be repaired successfully.
4. At this point, try to start the MySQL service :/etc/init.d/mysql start
.
Summarize
The above is in the Ubuntu VPS WordPress web site Open When prompted "set up a database connection error" solution, I hope this article on the content of the same problem with friends can help, if there is doubt you can message exchange.