晉三 發表於 2023-5-26 00:00:00

Ubuntu VPS中wordpress网站打开时提示”建立数据库连接错误”的解决办法

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