這篇文章主要介紹在MySQL中添加用戶名和密碼的方法,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)成都網(wǎng)站建設(shè)定制網(wǎng)站,是成都網(wǎng)站營(yíng)銷推廣公司,為PVC花箱提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計(jì)服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計(jì)、前端HTML5制作、后臺(tái)程序開(kāi)發(fā)等。成都網(wǎng)站營(yíng)銷推廣熱線:18982081108
在mysql中添加用戶名和密碼的方法:執(zhí)行【insert into mysql.user(Host,User,Password) values("localhost","用戶名",password("密碼"));】語(yǔ)句即可。
提醒:
本操作是在WIN命令提示符下,phpMyAdmin同樣適用。
用戶:phplamp 用戶數(shù)據(jù)庫(kù):phplampDB
具體方法如下:
1、新建用戶
//登錄MYSQL @>mysql -u root -p @>密碼 //創(chuàng)建用戶 mysql> insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234")); //刷新系統(tǒng)權(quán)限表 mysql>flush privileges;
這樣就創(chuàng)建了一個(gè)名為:phplamp 密碼為:1234 的用戶。
然后登錄一下。
mysql>exit; @>mysql -u phplamp -p @>輸入密碼 mysql>登錄成功
2、為用戶授權(quán)
//登錄MYSQL(有ROOT權(quán)限)。我里我以ROOT身份登錄. @>mysql -u root -p @>密碼 //首先為用戶創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)(phplampDB) mysql>create database phplampDB; //授權(quán)phplamp用戶擁有phplamp數(shù)據(jù)庫(kù)的所有權(quán)限。 >grant all privileges on phplampDB.* to phplamp@localhost identified by '1234'; //刷新系統(tǒng)權(quán)限表 mysql>flush privileges; mysql>其它操作 /* 如果想指定部分權(quán)限給一用戶,可以這樣來(lái)寫: mysql>grant select,update on phplampDB.* to phplamp@localhost identified by '1234'; //刷新系統(tǒng)權(quán)限表。 mysql>flush privileges; */
3、刪除用戶
@>mysql -u root -p @>密碼 mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost"; mysql>flush privileges; //刪除用戶的數(shù)據(jù)庫(kù) mysql>drop database phplampDB;
4、修改指定用戶密碼
@>mysql -u root -p @>密碼 mysql>update mysql.user set password=password('新密碼') where User="phplamp" and Host="localhost"; mysql>flush privileges;
以上是在mysql中添加用戶名和密碼的方法的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
新聞名稱:在mysql中添加用戶名和密碼的方法
文章網(wǎng)址:http://m.newbst.com/article26/gcsicg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、建站公司、網(wǎng)站營(yíng)銷、企業(yè)網(wǎng)站制作、網(wǎng)站建設(shè)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)