1. 停到运行的mysql: /etc/init.d/mysql stop文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
2. 使用skip-grant-tables这个选项启动MySQL: /usr/bin/mysqld_safe --skip-grant-tables &文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
3. 现在可以不用密码进入mysql 了。文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
# myql文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
> use mysql;文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
> UPDATE user SET password=password('123456') WHERE user='root'; //密码修改为123456;文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
> FLUSH PRIVILEGES;文章源自很文博客https://www.hinvn.com/很文博客-https://www.hinvn.com/51741.html
> quit;//退出mysql
4. 重启mysql : /etc/init.d/mysql restart
现在就可以用mysql -uroot -p123456登陆了。
评论