【发布时间】:2012-04-22 19:15:23
【问题描述】:
即使我使用以下命令重置了 root 密码,我也无法登录 MySQL:(列出的其他命令以提供更多信息)
# sudo dpkg-reconfigure mysql-server-5.1
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
# telnet 127.0.0.1 3306
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
# ps -Aw |grep mysql
26522 ? 00:00:00 mysqld
# /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
更新:
# sudo mysqladmin -u root password 123
mysqladmin: connect to server at 'localhost' failed
似乎 MySQL 运行不正常
更新: 我在 Ubuntu 下使用 MySQL 5.1。 直到我在 my.cnf 中进行一些更改以启用远程访问之前都可以。我撤消了我的更改,但问题没有解决! (也许我忘了撤消一些事情!)
更新:
# service mysql status
mysql start/running, process 26650
# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 26650
【问题讨论】:
-
使用mysqladmin命令创建root密码
-
抱歉,回复晚了 - 如果您还没有解决问题,请尝试发布您的 my.cnf 文件(当然不要包含敏感信息)。如果您正在玩远程访问,可以想象本地访问被意外禁用。还可以考虑在 my.cnf 文件中添加日志记录,以便更好地了解正在发生的事情(通过
log-error=/var/log/mysqld.log)。 -
@Lübnah 谢谢,我决定重新安装 MySQL。但是本地访问怎么可能被禁用呢?