MySQL創建數據庫時指定編碼utf8mb4和添加用戶


CREATE DATABASE `wordpress` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `wordpress` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 1.修改/etc/my.cnf 文件 [client] default-character-set = utf8mb4 [mysqld] character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci [mysql] default-character-set = utf8mb4 2.重啟Mysql服務 /etc/init.d/mysqld stop /etc/init.d/mysqld start

==================添加用戶及授權部分===================

摘自:Mysql創建、刪除用戶

2.3 授權test用戶擁有testDB數據庫的所有權限(某個數據庫的所有權限):

   mysql>grant all privileges on testDB.* to test@localhost identified by '1234';

  mysql>flush privileges;//刷新系統權限表

  格式:grant權限 on 數據庫.* to 用戶名@登錄主機 identified by "密碼";

2.4 如果想指定部分權限給一用戶,可以這樣來寫:

  mysql>grant select,update on testDB.* to test@localhost identified by '1234';

2.5 授權test用戶擁有所有數據庫的某些權限:

  mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

//test用戶對所有數據庫都有select,delete,update,create,drop 權限。

 //對localhost授權:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。


免責聲明!

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



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