mysql8.0授予用戶訪問權限


請注意版本為mysql8.0

創建用戶

方式一

create user zephyr identified by '123123';

方式二

create user zephyr@localhost identified by '123123'

用戶信息可以在mysql.user表中查詢,例如

select user, host
from mysql.user;

效果:

效果

注意:若不在創建用戶時指定host,則默認host為%。

授予訪問權限

授予zephyr訪問數據庫jdbc_learning的權限

grant select, insert, delete, update on jdbc_learning.* to zephyr@localhost;

注意:若host為%,則上述語句可改寫為:

grant select, insert, delete, update on jdbc_learning.* to zephyr;

省略了@localhost,因為%指代所有host

注意:mysql8.0不支持以下寫法:

grant select,insert,delete,update on jdbc_learning.* to zephyr@localhost identified by '123123';

會報錯:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '123123'' at line 1


免責聲明!

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



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