mysql登入串連、增加使用者、修改許可權

來源:互聯網
上載者:User

標籤:identified   password   修改密碼   create   使用者名稱   mysql   

登陸串連mysql

1 串連到mysql

mysql   -h主機地址  -u使用者名稱  -p密碼

例1:假設遠程主機的IP為:110.110.110.110,使用者名稱為root,密碼為abcd123。則鍵入以下命令:

mysql -h110.110.110.110 -uroot -pabcd123

(注:u與root可以不用加空格,其它也一樣)

2 退出mysql 命令:

exit

3 修改密碼

mysqladmin -u 使用者名稱 -p舊密碼 password 新密碼


 增加mysql的新使用者與修改許可權


1 grant 許可權 on 資料庫.* to 使用者名稱@登陸主機  identified by  "密碼";

  grant  all  on  *.*  to  *.*  to 使用者名稱@登陸主機  identified by "密碼";#這個使用者對所有的資料庫擁有所有的許可權。

2 create user :用於建立新的使用者賬戶(從5.0版本開始有這個命令),在建立這個使用者的時候不分配任何許可權,需要在建立之後通過grant命令來給改使用者指派相應的許可權。

eg:create user [email protected] identified by ’123456′; 

    grant select on mydb.* to [email protected];

3 drop user:刪除一個使用者賬戶

    eg:drop user guest;

4 rename user:可以實現重新命名一個使用者帳號。


5 grant:用於管理存取權限,也就是給使用者帳號授權。當然它同樣可以建立一個新的使用者賬戶。

  eg:

  grant select, insert, update, delete on new_db.* to [email protected]’%’ identified by ’888′;

  grant 許可權 on 資料庫.表 to 使用者 @ 訪問方式 identified by 密碼   grant select on mydb.* to [email protected] identified by ’123456′;

BTW:如果需要一個空密碼或者無密碼的賬戶,必須先用Create User命令,然後通過grant來分配許可權。如果如下操作:  grant all privileges on mydb.* to [email protected]’%’ ;

而在資料庫user表中沒有先建立visitor使用者,則會發生如下錯誤:

  "Can’t find any matching row in the user table"。

   grant只能創有密碼的賬戶。

6 revoke:刪除一個賬戶,具體查看MySQL的文檔


參考:http://see.xidian.edu.cn/cpp/u/mysql_ml/

本文出自 “天道酬勤” 部落格,請務必保留此出處http://luzhi1024.blog.51cto.com/8845546/1655471

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.