《Mysql學(xué)習(xí)Mysql中新建用戶及授權(quán)的方法分享》要點(diǎn):
本文介紹了Mysql學(xué)習(xí)Mysql中新建用戶及授權(quán)的方法分享,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
MYSQL數(shù)據(jù)庫(kù)在項(xiàng)目開發(fā)的過(guò)程中可能需要開放自己的數(shù)據(jù)庫(kù)給別人,但是為了安全不能自己服務(wù)器里其他數(shù)據(jù)庫(kù)同時(shí)開放.那么可以新建一個(gè)用戶,給該用戶開放特定數(shù)據(jù)庫(kù)權(quán)限
MYSQL數(shù)據(jù)庫(kù)測(cè)試環(huán)境:Centos 6.3和Mysql 5.3
MYSQL數(shù)據(jù)庫(kù)一、新建用戶
MYSQL數(shù)據(jù)庫(kù)這樣就創(chuàng)建了一個(gè)名為:cplusplus 密碼為:cplusplus.me 的用戶.
MYSQL數(shù)據(jù)庫(kù)二、登錄測(cè)試
MYSQL數(shù)據(jù)庫(kù)
mysql>exit;
@>mysql -u cplusplus -p
@>輸入密碼
mysql>登錄成功
MYSQL數(shù)據(jù)庫(kù)三、用戶授權(quán)
MYSQL數(shù)據(jù)庫(kù)
//登錄MYSQL
@>mysql -u root -p
@>密碼
//首先為用戶創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)(cplusplusDB)
mysql>create database cplusplusDB;
//授權(quán)cplusplus用戶擁有cplusplusDB數(shù)據(jù)庫(kù)的所有權(quán)限.
>grant all privileges on cplusplusDB.* to cplusplus@localhost identified by 'cplusplus.me';
//刷新系統(tǒng)權(quán)限表
mysql>flush privileges;
mysql>其它操作
MYSQL數(shù)據(jù)庫(kù)四、部分授權(quán)
MYSQL數(shù)據(jù)庫(kù)
mysql>grant select,update on cplusplusDB.* to cplusplus@localhost identified by 'cplusplus.me';
//刷新系統(tǒng)權(quán)限表.
mysql>flush privileges;
MYSQL數(shù)據(jù)庫(kù)五、刪除用戶
MYSQL數(shù)據(jù)庫(kù)
@>mysql -u root -p
@>密碼
mysql>DELETE FROM user WHERE User="cplusplus" and Host="localhost";
mysql>flush privileges;
MYSQL數(shù)據(jù)庫(kù)六、刪除數(shù)據(jù)庫(kù)
MYSQL數(shù)據(jù)庫(kù)
mysql>drop database cplusplusDB;
MYSQL數(shù)據(jù)庫(kù)七、修改密碼
MYSQL數(shù)據(jù)庫(kù)
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password('新密碼') where User="cplusplus" and Host="localhost";
mysql>flush privileges;
MYSQL數(shù)據(jù)庫(kù)給大家分享一則網(wǎng)友的經(jīng)驗(yàn):
MYSQL數(shù)據(jù)庫(kù)1.新建用戶
MYSQL數(shù)據(jù)庫(kù)用戶root權(quán)限登錄mysql,新建一個(gè)和數(shù)據(jù)庫(kù)同名的用戶
MYSQL數(shù)據(jù)庫(kù)
mysql> INSERT INTO mysql.user(Host,User,Password) VALUES('localhost', 'sun', password('sun123456'));
MYSQL數(shù)據(jù)庫(kù)刷新系統(tǒng)權(quán)限表
MYSQL數(shù)據(jù)庫(kù)
mysql> FLUSH PRIVILEGES;
MYSQL數(shù)據(jù)庫(kù)如果報(bào)錯(cuò)
MYSQL數(shù)據(jù)庫(kù)
#1364 C Field ‘ssl_cipher' doesn't have a default value
MYSQL數(shù)據(jù)庫(kù)修改MySQL配置文件linux系統(tǒng)為my.cnf,windows系統(tǒng)為my.ini
MYSQL數(shù)據(jù)庫(kù)
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
MYSQL數(shù)據(jù)庫(kù)修改為
MYSQL數(shù)據(jù)庫(kù)
sql_mode=NO_ENGINE_SUBSTITUTION
MYSQL數(shù)據(jù)庫(kù)重啟MySQL服務(wù)
MYSQL數(shù)據(jù)庫(kù)2.為用戶授權(quán)
MYSQL數(shù)據(jù)庫(kù)
mysql> GRANT ALL ON sun.* to sun@localhost identified BY 'sun123456';
mysql> FLUSH PRIVILEGES;
《Mysql學(xué)習(xí)Mysql中新建用戶及授權(quán)的方法分享》是否對(duì)您有啟發(fā),歡迎查看更多與《Mysql學(xué)習(xí)Mysql中新建用戶及授權(quán)的方法分享》相關(guān)教程,學(xué)精學(xué)透。維易PHP學(xué)院為您提供精彩教程。
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/13118.html