mysql 创建和删除用户
1.遠程登錄mysql
mysql -h ip -u root -p 密碼
2.創建用戶
? 格式:grant 權限 on 數據庫.* to 用戶名@登錄主機 identified by "密碼";
?? 例1:增加一個test1用戶,密碼為123456,可以在任何主機上登錄,并對所有數據庫有查詢,增加,修改和刪除的功能。需要在mysql的root用戶下進行
????mysql>grant select,insert,update,delete on *.* to test1@"%" identified by "123456";
??? mysql>flush privileges;
???? 例2:增加一個test2用戶,密碼為123456,只能在192.168.2.12上登錄,并對數據庫student有查詢,增加,修改和刪除的功能。需要在mysql的root用戶下進行
??? mysql>grant select,insert,update,delete on student.* to test2@192.168.2.12 identified by "123456";
???? mysql>flush privileges;
????? 例3:授權用戶test3擁有數據庫student的所有權限
????? mysql>grant all privileges on student.* to test3@localhost?identified by '123456';
???? mysql>flush privileges;
3.修改用戶密碼
???? mysql>update mysql.user set password=password('123456') where User='test1' and Host='localhost';
???? mysql>flush privileges;
4.刪除用戶
?? mysql>delete from user where user='test2' and host='localhost';
? mysql>flush privileges;
5.刪除數據庫和刪除表
? mysql>drop database 數據庫名;
?mysql>drop table 表名;
6.刪除賬戶及權限
? drop user 用戶名@'%'
? drop user 用戶名@localhost
總結
以上是生活随笔為你收集整理的mysql 创建和删除用户的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AS问题解决系列1—Unable to
- 下一篇: uber在限制新司机加入了,看看新政策把