mysql—Access denied for user 'root'@'localhost' (using password:NO)

安裝mysql未設置初始密碼,登陸提示Access denied for user 'root'@'localhost' (using password:NO):mysql

解決方案:sql

   sudo /etc/init.d/mysqld stop      //關閉mysql數據庫

       mysqld_safe --user=mysql --skip-grant-tables --skip-networking &    app

----------------------------------------------------------------------------------------this

mysqld_safe命令在啓動mysql,更新root帳號的密碼spa

--skip-grant-tables:不啓動grant-tables(受權表),跳過權限控制。code

--skip-networking :跳過TCP/IP協議,只在本機訪問(從網上有些資料看,這個選項不是必須的。能夠不用)ip

----------------------------------------------------------------------------權限控制

  打開新的命令窗口it

       mysql -u root mysql

       mysql> UPDATE user SET Password=PASSWORD('你想要的密碼') where USER='root';

       mysql> FLUSH PRIVILEGES;   //刷新權限

   另外,若是登陸mysql數據庫後執行腳本遭遇 ERROR 1820 (HY000): You must SET PASSWORD before executing this statement,可使用從新設置一次密碼便可解決問題.

   mysql>set password = password('p12#456'); 
相關文章
相關標籤/搜索