mysql创建用户
1. 创建用户:(只能从localhost登录)
mysql> create user 'user1'@'localhost' identified by 'pass1';
可以从任意地方登录
mysql> create user 'user1'@'%' identified by 'pass1';
2. 分配指定权限
mysql> grant select ,insert,update,delete on *.* to 'user1'@'localhost';
分配所有权限
mysql> grant all on *.* to 'user1'@'localhost';
分配用户访问指定数据库:
mysql> grant all on phplampdb.* to 'user1'@'localhost';
3. 创建用户同时分配权限:
mysql> grant all on *.* to 'user2'@'localhost' identified by 'pass1';
4. 刷新权限
mysql>flush privileges;
5. 删除用户
mysql>delete from user where user='user1' and host='localhost';
mysql>flush privileges;
删除用户的数据库
mysql> drop database phplampDB;
6. 修改密码:
mysql>update mysql.user set password = password('newpass')
where user='user1' and host='localhost';
7. 创建数据库
mysql> create database testdb default character set utf8 COLLATE utf8_general_ci;