2012-04-10 175 views
2

即使我重新用下面的命令root密码无法登录到MySQL:(上市提供额外的信息等命令)无法启动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 
+1

使用mysqladmin命令创建root密码 – kappa 2012-04-10 13:32:33

+0

对不起,我迟到的反应 - 如果你还没有固定的问题是,试图发布您的my.cnf文件(当然没有敏感信息)。如果您在远程访问时玩游戏,可以想象,本地访问被意外禁用。还可以考虑将日志记录添加到my.cnf文件中以更好地了解发生了什么(通过'log-error =/var/log/mysqld.log')。 – Matthematics 2012-04-17 17:02:40

+0

@Lübnah谢谢,我决定重新安装MySQL。但是,本地访问如何被禁用? – PHPst 2012-04-18 03:10:31

回答

2

设置root的密码:

mysqladmin -u root password NEWPASSWORD 

进行恢复: http://www.cyberciti.biz/tips/recover-mysql-root-password.html

+0

sudo mysqladmin -u root密码123 mysqladmin:在'localhost'连接服务器失败 – PHPst 2012-04-10 13:37:29

+0

是你的mysql服务器启动并运行了吗?尝试/etc/init.d/mysqld重新启动,看看会发生什么 – kappa 2012-04-10 16:37:27

+0

在您的第一个错误服务器响应,而在下一个块的情况是不同的。还是这样? – kappa 2012-04-11 07:43:22

2

我最好的猜测是,如果您已重新配置/重新安装MySQL,则需要无需密码登录,例如:

mysql -u root

甚至

mysql


编辑:要查看是否正在运行的服务,您可以尝试:

service mysqld status

,如果它没有运行,请尝试:

service mysqld start然后再次检查状态。

+0

无效 – PHPst 2012-04-10 13:38:18

+0

尝试上面编辑的第二部分,可能是mysql服务没有运行。我最近遇到过这个问题。 – Jonathan 2012-04-10 13:52:58

+0

/sbin /服务mysqld状态 -bash:/ sbin/service:没有这样的文件或目录 – PHPst 2012-04-10 13:59:44

1

这似乎是MySQL绝对没有运行。您可以用/etc/init.d/mysqld statusservice mysqld status(不要直接链接到服务命令)来验证。

我的spidey感告诉我你的O/S或MySQL安装不正确。这将有助于了解更多关于您正在运行的(linux?)环境以及它如何配置(或者谁配置它,在PaaS中)的信息。

0

开始作为一种服务

sudo的服务mysql的重启

验证&检查服务和端口

须藤netstat的抽头| grep的MySQL的

Screen shot of check the mysql service running

0

你应该改变的访问权限。它应该是0644

sudo chmod 644 /etc/mysql/my.cnf 

然后

sudo dpkg-reconfigure mysql-server-5.5