mysql5.7 修改root密码


1.编辑MySQL配置文件(忽略授权表) #编辑文件,找到[mysqld],在下面添加一行skip-grant-tables

  vi /etc/my.cnf

  [mysqld]

  skip-grant-tables

  :wq! #保存退出

2.重启服务

 #service mysql restart


(-my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.

Starting MySQL

-chmod 644 /etc/my.cnf)


3.进入mysql,因为之前已经跳过输入密码登陆,直接回车就可以进入

 #mysql -uroot -p  

4.修改密码,这里跟之前的改密码的字段不一样,

 >update mysql.user set authentication_string=password(‘newpass‘) where user=‘root‘;

 >flush privileges

 >quit

5.将/etc/my.cnf文件 skip-grant-tables注释掉,重启服务

 #service mysql resart

6.使用 mysql -uroot -p 输入密码 就可以进了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章