Linux VPS服务器忘记MYSQL数据库ROOT密码解决方案

出于各种原因我们凭借脑袋记忆的MYSQL密码或者本地保存的MYSQL数据库密码丢失的可能肯定是存在的,出现问题并不可怕,我们只要找到合适的方法解决问题就可以。上午的时候一个网友使用LLsMP一键包VPS建站环境,有出现找不到MYSQL数据库ROOT密码,无法进行PHPMYADMIN数据库管理,这不现在本站有点时间把解决方法整理出来,以便如果以后有遇到同类问题的朋友可以直接解决。

第一、修改MYSQL登录设置

vi /etc/my.cnf

编辑my.cnf文件,在[mysqld] 中添加skip-grant-tables一行。

添加如图所示,然后:wq保存退出。

第二、重启MYSQLD

/etc/init.d/mysqld restart

第三、准备修改MYSQL密码

[[email protected] ~]# /usr/bin/mysql Welcome to the MySQL monitor.  Commands end with ; or \\g. Your MySQL connection id is 2 Server version: 5.0.95 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type \’help;\’ or \’\\h\’ for help. Type \’\\c\’ to clear the current input statement.

mysql> USE mysql ; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Database changed mysql> UPDATE user SET Password = password ( \’laozuo.org\’ ) WHERE User = \’root\’ ; Query OK, 3 rows affected (0.00 sec) Rows matched: 3  Changed: 3  Warnings: 0

mysql> flush privileges ; Query OK, 0 rows affected (0.00 sec)

mysql> quit Bye

红色部分是我们需要输入的,设置密码为laozuo.org,这个我们可以自己定义新密码,或者后面自己修改。

第四、编辑/etc/my.cnf 文件

把开始添加的skip-grant-tables一行删除,然后保存退出。

最后,重启MYSQLD

/etc/init.d/mysqld restart

重启MYSQLD之后,我们就可以通过PHPMYADMIN登录MYSQL管理,且用重置的新密码就可以登录。

推荐站内搜索:新加坡服务器、域名空间代理、国内免备案cdn、山东网站备案、服务器怎么搭建、上海域名注册、美国网站服务器、网页备案、虚拟主机香港主机、注册域名、