欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql創(chuàng)建數(shù)據(jù)庫,添加用戶,用戶授權(quán)實(shí)操方法

 更新時(shí)間:2019年10月28日 16:36:36   作者:山中自有人  
在本篇文章里小編給大家整理的是關(guān)于mysql創(chuàng)建數(shù)據(jù)庫,添加用戶,用戶授權(quán)實(shí)操方法相關(guān)知識點(diǎn),需要的朋友們學(xué)習(xí)下。

一、創(chuàng)建mysql數(shù)據(jù)庫

1.創(chuàng)建數(shù)據(jù)庫語法

--創(chuàng)建名稱為“testdb”數(shù)據(jù)庫,并設(shè)定編碼集為utf8
CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

二、創(chuàng)建用戶

1.新建用戶

 --創(chuàng)建了一個(gè)名為:test 密碼為:1234 的用戶
 create user 'test'@'localhost' identified by '1234';

注意:
此處的"localhost",是指該用戶只能在本地登錄,不能在另外一臺機(jī)器上遠(yuǎn)程登錄。如果想遠(yuǎn)程登錄的話,將"localhost"改為"%",表示在任何一臺電腦上都可以登錄。也可以指定某臺機(jī)器可以遠(yuǎn)程登錄。

2.查詢用戶

--查詢用戶
select user,host from mysql.user;

3.刪除用戶

--刪除用戶“test”
drop user test@localhost ;
--若創(chuàng)建的用戶允許任何電腦登陸,刪除用戶如下
drop user test@'%';

4.更改密碼

--方法1,密碼實(shí)時(shí)更新;修改用戶“test”的密碼為“1122”
set password for test =password('1122');
--方法2,需要刷新;修改用戶“test”的密碼為“1234”
update mysql.user set password=password('1234') where user='test'
--刷新
flush privileges;

5.用戶分配權(quán)限

--授予用戶test通過外網(wǎng)IP對數(shù)據(jù)庫“testdb”的全部權(quán)限
grant all privileges on 'testdb'.* to 'test'@'%' identified by '1234'; 

--刷新權(quán)限
flush privileges; 

--授予用戶“test”通過外網(wǎng)IP對于該數(shù)據(jù)庫“testdb”中表的創(chuàng)建、修改、刪除權(quán)限,以及表數(shù)據(jù)的增刪查改權(quán)限
grant create,alter,drop,select,insert,update,delete on testdb.* to test@'%';   

6.查看用戶權(quán)限

--查看用戶“test”
show grants for test;

注意:修改完權(quán)限以后 一定要刷新服務(wù),或者重啟服務(wù),刷新服務(wù)用:flush privileges;

以上就是本次介紹的全部相關(guān)知識點(diǎn)內(nèi)容,感謝大家的學(xué)習(xí)和對腳本之家的支持。

相關(guān)文章

最新評論