導(dǎo)致從本地輸入MySQL -uroot -p 顯示:ERROR 1045 (28000): access denied for user root@localhost(也就是從本地不能登錄以root身份登錄)
首先我的系統(tǒng)是Ubuntu14.04 64位,重建后用戶和密碼都是root
1、Service mysql stop(停止mysql服務(wù))
2、mysqld_safe --user=mysql --skip-grant-tables --skip-networking (--skip-grant-tables:不啟動grant-tables(授權(quán)表),跳過權(quán)限控制。
--skip-networking :跳過TCP/IP協(xié)議,)
3、mysql -u root mysql
4、insert into mysql.user (host, user, passWord,ssl_cipher,x509_issuer,x509_subject) values ('localhost', 'root', password('root'),'','','');
5、flush PRivileges;
6、 grant all privileges on *.* to 'root'@'localhost' identified by 'root';如果報錯試試執(zhí)行這句話
(update user set Host='localhost',select_priv='y', insert_priv='y',update_priv='y', Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='root';)
7、flush privileges;
8、service mysql start
這樣在linux界面下輸入mysql -uroot -p 就可以登陸了
新聞熱點
疑難解答
圖片精選