MySQL創建新用戶以及ERROR 1396 (HY000)問題解決


 登 錄mysql

 mysql -u root -p

創建允許本地 IP訪問localhost的Mysql數據庫時出錯

 create user 'lijing'@'localhost' identified by '147258369';

ERROR 1396 (HY000): Operation CREATE USER failed for 'lijing'@'localhost'

 出錯原因:

Assume the user is there, so drop the user
After deleting the user, there is need to flush the mysql privileges
Now create the user.

以下解決辦法:

創建允許本地 IP訪問localhost的Mysql數據庫:

 drop user 'lijing'@'localhost';

 flush privileges;刷新系統權限表)

 create user 'lijing'@'localhost' identified by '147258369';

創建允許外網IP訪問數據庫lijing,本命令包含上面的命令,是所有的IP都可以訪問該數據庫

create user 'lijing'@'%' identified by '147258369';258369';

 創建成功后查詢創建的用戶是否成功

 select host,user,authentication_string from mysql.user;

創建一個新的數據庫,並使用show databases命令查看數據庫是否創建OK

 create database lijingdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

show databases;

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM