Ubuntu 16.04 Mysql 重置密码

如下的处理,是在mysql 的mysql.user表的 加密使用的是mysql_native_password的状况,若是不是请参考文章的末尾 部分:mysql

 

1. 登陆不到mysql内的状况下,非生产环境,建议修改配置文件/etc/mysql/my.cnfsql

数据库

[mysqld]的地方添加:bash

skip-grant-tables

而后重启mysqlide

sudo service mysql restart 

 直接免密码进入数据库:加密

mysql 

按照其余人的教程是:spa

update user  set password=password("new_passsword")  where user = 'root';

flush privileges;

重启mysql便可。rest

可是在有的mysql.user表中,password列会被authentication_string 列名代替,这就要咱们手动修改一下上述的列名便可。code

 

update  user set authentication_string=password("new_passoword") where user = "root";
flush privileges;

  

ok ,完活!blog

2.能够进入mysql修改root

步骤同上。

密码修改完毕之后,记得要将上述的

skip-grant-tables

 注释掉,而后重启mysql 

 

受权 子用户的语法格式 :

grant all privileges on databases_name.*  to user_name@'allow_ip' identified by 'password';

  

Attention :

若是屡次处理,用户的密码仍旧不正确,请在跳过密码登陆后,查看表

select * from mysql.user\G

  查看root用户的plugin 列,采用的加密规则,若是不是mysql_native_password ,那么须要修改;

sql语句以下:

use mysql;
update user set plugin='mysql_native_password' where user = 'root';

 问题 就能够解决喽

相关文章
相关标签/搜索