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

來源:互聯網
上載者:User

標籤:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.