一、发现问题在尝试编辑博客站点的Wordpress主题时,突然发现博客站点无法连接;刷新后提示“建立数据库连接错误”之类的错误。自然想到是mysql可能出错了,所以就登陆了VPS主机,尝试启动mysql服务,但是提示failed。
二、解决方法1、打开
/var/log/mysql/error.log
文件,查看出错日志。在阅读日志时发现第一条错误提示是
:[ERROR] Can"t open the mysql.plugin table. Please run mysql_upgrade to create it.
2、尝试执行
mysql_upgrade
依然提示错误:
Looking for "mysql" as: mysqlLooking for "mysqlcheck" as: mysqlcheckError: Failed while fetching Server version! Could be due to unauthorized access.FATAL ERROR: Upgrade failed
3、于是,在网上搜索类似问题时,找到了解决办法。输入命令:
mysql_install_db --user=mysql --ldata=/var/lib/mysql
后,会自动安装
system tables
,即可成功修复。
4、此时,尝试启动mysql服务
:/etc/init.d/mysql start
即可。
总结以上就是在Ubuntu VPS中wordpress网站打开时提示”建立数据库连接错误”的解决办法,希望本文的内容对同样遇到这个问题的朋友们能有所帮助,如果有疑问大家可以留言交流。