SHOW DATABASES;
CREATE DATABASE 庫名;mysql
CREATE DATABASE `sms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;sql
建立用戶並賦權:數據庫
grant all privileges on sms.* to `sms`@`localhost` identified by 'sms'; flush privileges;
grant 權限1,權限2,…權限n on 數據庫名稱.表名稱 to 用戶名@用戶地址 identified by ‘鏈接口令’;ide
mysql>grant select,insert,update,delete,create,drop on sms.sendtable to sms@192.168.26.11 identified by ‘123′;
給來自192.168.26.11的用戶sms分配可對數據庫sms的sendtable表進行select,insert,update,delete,create,drop等操做的權限,並設定口令爲123。
mysql>grant all privileges on sms.* to sms@192.168.26.11 identified by ‘123′;
給來自192.168.26.11 的用戶sms分配可對數據庫sms全部表進行全部操做的權限,並設定口令爲123。
mysql>grant all privileges on *.* to sms@192.168.26.11 identified by ‘123′;
給來自192.168.26.11 的用戶sms分配可對全部數據庫的全部表進行全部操做的權限,並設定口令爲123。
mysql>grant all privileges on *.* to sms@localhost identified by ‘123′;
給本機用戶sms分配可對全部數據庫的全部表進行全部操做的權限,並設定口令爲123。.net
撤銷權限用revokecode
revoke 跟 grant 的語法差很少,只須要把關鍵字 「to」 換成 「from」接口