標籤:常用sql grant 預設 127.0.0.1 改ip 命令 指定 修改ip 情況下
13.4 mysql使用者管理
[[email protected] ~]# mysql -uroot -p‘taoyuan‘ //登入mysql> grant all on *.* to ‘user1‘@‘172.0.0.1‘ identified by ‘123456‘;#建立user使用者並授予其所有許可權“*.*”(萬用字元)#第一個*表示db_name;第二個*表示tb_name#同時指定其來源IP127.0.0.1(即,只可通過此IP登入)#此處可以使用萬用字元%,代表所有IP(一般不使用)#identified by :設定密碼#quit 退出[[email protected] ~]# mysql -uuser1 -p123456 -h127.0.0.1
使用socket登入
#登入root使用者mysql> grant all on *.* to ‘user1‘@‘localhost‘ identified by ‘123456‘;Query OK, 0 rows affected (0.01 sec)#授權localhost#登入[[email protected] ~]# mysql -uuser1 -p123456
說明: 因為指定登入主機為localhost,所以該使用者預設使用(監聽)本地mysql.socket檔案,不需要指定IP即可登入。
[[email protected] ~]# mysql -urootmysql> show grants;#查看目前使用者的許可權mysql> show grants for [email protected]‘127.0.0.1‘;#查看指定使用者的許可權mysql> GRANT SELECT, INSERT, UPDATE ON `db1`.* TO ‘user2‘@‘192.168.1.15‘; Query OK, 0 rows affected (0.01 sec)#在不知道密碼的情況下,可以直接用show grants命令進行複製,修改ip地址 增加。
mysql使用者管理、常用sql語句、mysqlDatabase Backup恢複