mysql 数据库忘记了密码处理

在安装完了忘记了登陆数据库的密码,可以做以下的处理:

1、修改root密码

sudo more /etc/mysql/debian.cnf

用文件里的用户名密码登陆Mysql

use mysql

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

update user set authentication_string=password('123') where user='root';

flush privillege;

2、配置远程访问数据库

注释掉在/etc/MySQL/mysql.conf.d/mysqld.cnf里面的bind-address = 127.0.0.1

连接mysql数据库,修改user表

Grantall on *.* to 'root'@'%' identifiedby 'root用户的密码' withgrant option;flush privileges;

猜你喜欢

转载自my.oschina.net/u/1780456/blog/1835116
今日推荐