標籤:
MySQL安裝完server端和用戶端後,登入Mysql時報錯:
[[email protected] MySQL 5.6.23-RMP]# mysql
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)
[[email protected] MySQL 5.6.23-RMP]# service mysql start
Starting MySQL.[ OK ]
[[email protected] 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