1 新建用户
mysql -u root -p
输入密码
后进入mysql 命令行管理
insert into mysql.user(Host,User,Password) values('localhost','admin',password('123456'));
//刷新系统权限表
mysql> flush privileges;
2创建数据库
create database newdatabase;
3为用户授权
mysql>grant all privileges on newdatabase.* to admin@localhost identified by '123456';
mysql>flush privileges;
也可以授予该用户特定的权限
grant select, insert,update,delete on newdatabase.* to admin@localhost identified by '123456';
共14种权限 select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file
mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。
mysql>grant all privileges on *.* to joe@10.163.225.87 identified by ‘123′;
给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;
给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
4.删除用户
@>mysql -u root -p
@>密码
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
//删除用户的数据库
mysql>drop database phplampDB;
5.修改指定用户密码
@>mysql -u root -p
@>密码
mysql>update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";
mysql>flush privileges;
mysql>quit;