mysqllocalhost沒法登錄

關於mysql localhost沒法登錄的問題

提示」ACCESS DENIED FOR USER ‘ROOT’@’LOCALHOST’ (USING PASSWORD: YES)」

1.是否被修改了root密碼

  • /etc/init.d/mysql stop
    mysqld_safe –skip-grant-tables &
    mysql -uroot -p
    mysql>update mysql.user set password=password(‘mypassword’) where user=’root’;
    mysql>flush privileges;
    mysql>quit

    2.localhost是否沒有映射到root

    • mysql -u root -p -h 127.0.0.1
      grant all privileges on . to ‘root’@’localhost’ identified by ‘mypassword’ with grant option;
      grant all privileges on . to ‘root’@’118.192.91.xxx’ identified by ‘mypassword’ with grant option;
  • select user,host,password from user; 再查詢用戶表
  • mysql -h localhost和mysql -h 127.0.0.1的區別,經過localhost鏈接到mysql是使用UNIX socket,而經過127.0.0.1鏈接到mysql是使用TCP/IP
  • 查看狀態 mysql -h localhost > status問題解決。
相關文章
相關標籤/搜索