遠程鏈接Linux mysql報錯:Access denied for user ‘root’@‘localhost’(using password: YES)的解決方法

在新安裝好的Centos7上剛安裝好mysql,準備進去看看,可是登錄的時候,發現報錯啦:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes)
如何解決呢?mysql

  1. 先中止mysql 服務
service mysqld stop
  1. 跳過密碼驗證
/usr/bin/mysqld_safe --skip-grant-tables
  1. 使用root帳戶,無密碼登陸,修改root用戶密碼
mysql -u root 
use mysql
update user set password=PASSWORD("你的密碼") where User = 'root'; 

4.重啓mysql,正常登陸sql

service mysqld restart

能夠啦~~~bash

做者:段佳偉的大憩屋 連接:https://www.jianshu.com/p/d86d97f1bf97 來源:簡書 簡書著做權歸做者全部,任何形式的轉載都請聯繫做者得到受權並註明出處。
相關文章
相關標籤/搜索