MySQL 忘记密码怎么办
source link: https://www.codesky.me/archives/mysql-forget-password.wind
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
MySQL 忘记密码怎么办
之前浪费钱对于个人服务器也开通了 DB 和服务的隔离,现在看来不过是浪费钱,所以想要合并一下,结果发现!Service 服务器上安装好了 MySQL!我!却!把密!码!忘!了!
找了找之后发现还是可以抢救一下的:
找到配置文件地址
mysql --help | grep -A 1 "Default options"
Ubuntu 16 可能在这个位置:/etc/mysql/mysql.conf.d/mysqld.cnf
vim /etc/mysql/mysql.conf.d/mysqld.cnf
在 [mysqld]
的下一行加上:skip-grant-tables
sudo service mysql restart
之后可以不用密码登录了:mysql -u root
修改密码:
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass';
完成后记得把 skip-grant-tables
删掉(或者注释掉),否则是一个巨大的安全隐患。
如果您觉得文章不错,可以通过赞助支持我。
如果您不希望打赏,也可以通过关闭广告屏蔽插件的形式帮助网站运作。
- 上一篇: Docker Mysql DB 初始化 UTF8 乱码问题的解决
- 下一篇: 没有了
添加新评论
称呼
网站
内容
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK