MySQL忘记密码
1:杀之
pkill mysqld
2:打开忽略授权表参数
vi /etc/my.cnf
[mysqld]
skip-grant-tables
3:启动,mysql进入,执行修改
mysql
三选一
UPDATE user SET PASSWORD=PASSWORD('111111') where USER='root';
FLUSH PRIVILEGES;
update mysql.user set password=password("111111") where user='root' and host='hostname';
update mysql.user set authentication_string=password('111111') where user='root';
刷新
mysql> flush privileges;
4:恢复原来的配置,正常启动
设置远程访问
GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '111111' WITH GRANT OPTION;
FLUSH PRIVILEGES;
还需要注意mysql.socket所在文件夹对应的权限(chmod 777 /tmp)
mysql本地无法登陆,可能账户不优先
mysql> select host,user from mysql.user;
mysql> drop user ''@localhost;
浙公网安备 33010602011771号