linux 創建數據庫


mysql -uroot -pxxxxxx

1. 修改服務器的字符集

打開/etc/mysql/my.cnf,在[mysqld]后添加character-set-server=utf8

 

2. 查看mysql當前的字符集

 

show grants for 你的用戶

show variables like 'character_set_%';

set names utf8;    //設定字符集

create database edc_v2 charset utf8   //創建數據庫

use edc_v2 //切換數據庫

show databases //查看當前mysql有多少個數據庫

 show tables //顯示當前一共有哪些表

describe table //顯示表結構  desc table 

3. 創建數據庫用戶

 1. set names utf8 //先設定客戶端字符集

2. create database dbname charset utf8   //創建數據庫

3. create user 'zhangsan'@'%' identified by 'password' 

4. create user 'zhangsan'@'localhost' identified by 'password' //本地可以使用

5. grant select,insert,update,delete,create on dbname.* to 'zhangsan'@'localhost' ; 

6. grant select,insert,update,delete,create on dbname.* to 'zhangsan'@'%' ; 

7. flush privileges 

 

 

 

 

3. use dbname  //切換數據庫

 

4. grant select,insert,update,delete,create on wwlm_kankan_v2.* to 'w2'@'localhost' ;

 

3.1 create user '[用戶名稱]'@'%' identified by '[用戶密碼]';--創建用戶

create user 'edc_v2'@'localhost' identified by 'password'

 create user 'edc_v2'@'%' identified by 'password'

) ;

  密碼8位以上,包括:大寫字母、小寫字母、數字、特殊字符

  %:匹配所有主機,該地方還可以設置成‘localhost’,代表只能本地訪問,例如root賬戶默認為‘localhost‘

3.2 grant select,insert,update,delete,create on [數據庫名稱].* to [用戶名稱];--用戶授權數據庫

  *代表整個數據庫

3.3 flush  privileges ;--立即啟用修改

3.4 revoke all on *.* from tester;--取消用戶所有數據庫(表)的所有權限

3.5 delete from mysql.user where user='tester';--刪除用戶

3.6 drop database [schema名稱|數據庫名稱];--刪除數據庫


免責聲明!

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



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