4

MySQL 忘记密码怎么办

 3 years ago
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.
neoserver,ios ssh client

MySQL 忘记密码怎么办

之前浪费钱对于个人服务器也开通了 DB 和服务的隔离,现在看来不过是浪费钱,所以想要合并一下,结果发现!Service 服务器上安装好了 MySQL!我!却!把密!码!忘!了!

找了找之后发现还是可以抢救一下的:

找到配置文件地址

  1. 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

  1. sudo service mysql restart

之后可以不用密码登录了:mysql -u root

修改密码:

  1. mysql> FLUSH PRIVILEGES;
  2. mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass';

完成后记得把 skip-grant-tables 删掉(或者注释掉),否则是一个巨大的安全隐患。

如果您觉得文章不错,可以通过赞助支持我。

如果您不希望打赏,也可以通过关闭广告屏蔽插件的形式帮助网站运作。

标签: 知识, mysql

添加新评论

称呼

Email

网站

内容


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK