经常给别人安装lnmp但是安装时间过长MYSQL密码容易忘记,在这里给大家介绍下如何更改密码。
1.停掉LNMP
/root/lnmp stop
2.修改MYSQL配置文件
vim /etc/my.cnf
光标到[mysqld]后面按一次“i”进入插入模式,然后按enter回车输入“skip-grant-tables”,在按ESC输入“:wq”回车即可保存。
3.启动LNMP
/root/lnmp start
4.修改密码
mysql
update user set Password = password ( '123456' ) where user = 'root' ;
exit
其中123456就是你的新密码,别忘记最后的分号要不然是不会更新好的。
MySql 5.7.19 忘记密码:
update mysql.user set authentication_string=PASSWORD('你的密码') where User='root';
flush privileges;
5.将刚才配置过的my.cnf修改回来,删除掉skip-grant-tables即可,这样安全。
6.重启LNMP。
/root/lnmp restart
来自:http://jinzhe.net/post/42.html
Windows是my.ini,Linux是my.cnf:
1.停掉LNMP
/root/lnmp stop
2.修改MYSQL配置文件
vim /etc/my.cnf
光标到[mysqld]后面按一次“i”进入插入模式,然后按enter回车输入“skip-grant-tables”,在按ESC输入“:wq”回车即可保存。
3.启动LNMP
/root/lnmp start
4.修改密码
mysql
update user set Password = password ( '123456' ) where user = 'root' ;
exit
其中123456就是你的新密码,别忘记最后的分号要不然是不会更新好的。
MySql 5.7.19 忘记密码:
update mysql.user set authentication_string=PASSWORD('你的密码') where User='root';
flush privileges;
5.将刚才配置过的my.cnf修改回来,删除掉skip-grant-tables即可,这样安全。
6.重启LNMP。
/root/lnmp restart
来自:http://jinzhe.net/post/42.html
Windows是my.ini,Linux是my.cnf:
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/8048/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2018-11-26 17:32
评论列表