码迷,mamicode.com
首页 > 数据库 > 详细

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO

时间:2015-04-13 16:22:35      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:

MySQL安装完server端和客户端后,登录Mysql时报错:
[root@rhel204 MySQL 5.6.23-RMP]# mysql
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)
[root@rhel204 MySQL 5.6.23-RMP]# service mysql start
Starting MySQL.[ OK ]
[root@rhel204 MySQL 5.6.23-RMP for oraclelinux or rhel5-x86-64V74393-01]# mysql ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO
安装过程中并没有设置过任何密码,重装多次也是如此。。。。。
==========================
处理方法:
Reset Forgotten MySQL Root Password:
First things first. Log in as root and stop the mysql daemon.

sudo /etc/init.d/mysql stop

Now lets start up the mysql daemon and skip the grant tables which store the passwords.

sudo mysqld_safe --skip-grant-tables&

(press Ctrl+C now to disown the process and start typing commands again)

You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

sudo mysql --user=root mysql

update user set Password=PASSWORD(‘new-password‘);
flush privileges;
exit;

Now kill your running mysqld then restart it normally.

sudo killall mysqld_safe&
(press Ctrl+C now to disown the process and start typing commands again)
/etc/init.d/mysql start

You should be good to go. Try not to forget your password again.

https://www.howtoforge.com/reset-forgotten-mysql-root-password

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO

标签:

原文地址:http://www.cnblogs.com/rusking/p/4422326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!