mysql 資料庫賬戶設定

來源:互聯網
上載者:User

標籤:mysqld   ica   blank   set   cipher   pre   int   root使用者   0 rows   

1,資料庫的備份:pro:需要備份的資料庫;mypro.sql:備份產生的備份檔案

C:\Users\jfhlg>mysqldump -u root -p pro>mypro.sql//備份root賬戶下的pro資料庫,備份檔案命名為mypro.sql 
Enter password: ******                /備份檔案儲存地址為預設路徑C:\Users\jfhlg

C:\Users\jfhlg>mysqldump -u root -p pro>d:\mypro.sql //備份到指定路徑d:\
Enter password: ******

C:\Users\jfhlg>

 2,資料庫的還原:mypdb:接受還原檔案的資料庫;mypro.sql:將要還原的備份檔案

方法一:
C:\Users\jfhlg>mysql -u root -p mydb<C:\Users\jfhlg\mypro.sql //將備份檔案mypro.sql還原到指定的資料庫(mydb)裡面;Enter password: ******              /如果mydb和mypro有相同名字的表,則mydb中的表將被替換,二不同名的表被保留

方法二:
mysql> source C:\Users\jfhlg\mypro.sql   //將mypro.sql還原到當前所在的資料庫中
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

···

 3,建立使用者:新建立的使用者至少需要擁有insert許可權才能建立其他使用者;新建立的使用者沒有任何許可權;

方法一:create user ‘jingfahong‘@‘localhost‘ identified by ‘123456‘; 
//建立使用者 ‘jingfahong’:使用者名稱;‘localhost’:伺服器位址;‘123456’:密碼(不設密碼時底線部分可以省略);方法二:insert into mysql.user(host,user,authentication_string,ssl_cipher,x509_issuer,x509_subject)values(‘localhost‘,‘jfh‘,password(‘123456‘),‘‘,‘‘,‘‘);//使用方法二建立使用者帳號後,可能需要使用‘flush privileges’語句重新整理資料庫後才會生效

 4,修改使用者密碼:

方法一:在登陸賬戶前修改(會要求輸入原密碼)mysqladmin -u jinghong -p password 111222方法二:在擁有足夠許可權的賬戶(root使用者)內通過以下語句修改指定賬戶的密碼(可能需要flush privileges重新整理之後才能看見)update mysql.user set authentication_string=password(‘111222‘) where host=‘localhost‘ and user=‘jinghong‘;set password for ‘jinghong‘@‘localhost‘=password(‘111222‘);

方法三:在已經登陸且有修改密碼許可權的情況下,可用以下語句修改自身的密碼set password=password(‘111222‘);

 

5,查看使用者的許可權:新建立的使用者至少需要擁有select許可權才可以查看其他使用者的資訊(但是可以查看自己擁有的許可權)

show grants for ‘jfh‘@‘localhost‘;//查看許可權

 6,授予使用者權限:許可權詳情請前往:http://www.cnblogs.com/Richardzhu/p/3318595.html

grant select,insert on *.* to ‘jfh‘ @ ‘localhost‘ with grant option;//授權給jfh使用者
/其中*.* 左邊的*表示所有的資料庫,右邊的*表示所有的資料表;*也可以換成指定的資料庫和資料表,則表示對指定的庫和表有存取權限
/另外;with grant option 表示可以給其它使用者授權的許可權(可以授於的許可權不能超過自己擁有的許可權)

 7,收回許可權:

1,收回指定使用者的指定許可權:收回jinghong使用者的insert許可權revoke insert on *.* from ‘jinghong‘@‘localhost‘;2,收回指定使用者的全部許可權;revoke all privileges,grant option from ‘jinghong‘@‘localhost‘;

 

mysql 資料庫賬戶設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.