(1)用户管理
1)登录和退出mysql
例:
mysql -h192.168.111.150 -P3306 -uroot -predhat mysql -e 'select user,host,authentication_string from mysql.user'
-h 指定主机名 [默认为localhost]
-P MySQL端口 [默认为3306]
-u 指定用户名 [默认为root]
-p 指定登录密码 [默认为空]
此处mysql为指定登录的数据库
-e 接SQL语句
2)创建用户
方法一:create user语句创建
create user user1@'localhost' identified by 'password';
方法二:grant 语句创建
grant all on . to 'user1'@'localhost' identified by 'password';
grant all on blog.* to 'user2'@'%' identified by 'password';
3)删除用户
- 方法一:drop user
drop user 'user1'@'localhost'; 方法二:delete语句删除
delete from mysql.user where user='user1' and host='localhost';
flush privileges;4)修改用户密码