【发布时间】:2017-06-18 12:08:03
【问题描述】:
我正在尝试在 MysqlPasswordReset 之后重置 root 密码,但是当我尝试使用 --skip-grant-tables 启动服务器时,服务器无法启动
- Ubuntu 16.04.1 LTS(GNU/Linux 4.4.0-59-generic x86_64)
- mysql Ver 14.14 Distrib 5.7.17,适用于 Linux (x86_64)
服务器正在运行
$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
停止服务器
$ sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
尝试从 --skip-grant-tables 开始
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
[1] 9856
无密码连接
$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
[1]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
我也尝试从mysql_safe开始(error.log为空)
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.
【问题讨论】:
-
在使用安全模式时可以使用root连接吗?你试过没有
--skip-networking吗? -
@davejal 是的,我试过不使用 --skip-networking 并且无法在安全模式下连接到 mysql 服务器
标签: mysql ubuntu ubuntu-16.04 root change-password