- 进入安全模式 sudo mysqld-safe --skip-grant-tables --skip-networing
备注:此处输入的密码为ubuntu系统的管理员密码
2.打开新的terminal界面 mysql -u root
3.重置MySQL密码
4.重启mysqld
5.重新登陆MySQL mysql -u root -p
其他问题:
运行安全模式的时候提示 mysqld for UNIX socket file don't exists. 的解决办法
sudo mysqld_safe --skip-grant-tables
2017-02-01T16:33:31.382105Z mysqld_safe Logging to syslog.
2017-02-01T16:33:31.383942Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-02-01T16:33:31.386058Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-02-01T16:33:31.388009Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
1.service mysql stop 关闭服务器
2.mkdir -p /var/run/mysqld 创建路径
3.chown mysql:mysql /var/run/mysqld 获取管理员权限
然后运行 sudo mysqld_safe --skip-grant-tables --skip-networking