好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

linux中清空Mysql数据库ROOT密码教程

root密码如果我们在安装mysql时设置了密码那么我们希望它之后变成空密码要怎么办呢?下面我们就一起来看看具体的解决办法吧。

一、方法一

1)进入var/lib/mysql

2)删除掉mysql文件

3)重新启动mysql,到此密码已经清空.

4)设置新的密码:

  • echo  "grant all on *.* to 'root'@'localhost' identified by 'newpass';"  | mysql -uroot 
  • echo "grant all on *.* to 'root'@'%' identified by 'newpass';"  | mysql -uroot  -pnewpass   --phpfensi.com

    二、方法二

    1)停止mysql服务

    2)跳过权限检查启动 mysql /usr/bin/mysqld_safe --skip-grant-tables &  

    注: 参数--skip-grant-tables为跳过授权表,--skip-networking为不监听TCP/IP连接)

    4)执行MYSQL客户端:mysql

    5)使用mysql数据库:use mysql;

    6)更新root密码:update user set password='' where user='root';这里是加一个空密码给root;

    7)关闭mysql服务器,用正常方试起动.

    三、方法三

    1)#mysql -u root -p进入mysql管理

    2)mysql> set password for root@localhost=password('');

    3) mysql>exit;

    其实就是把它的密码设置为空就可以了.

    查看更多关于linux中清空Mysql数据库ROOT密码教程的详细内容...

  •   阅读:76次