创建新的用户:
CREATE USER ‘native‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘password‘;
OR
CREATE USER ‘native‘@‘localhost‘ IDENTIFIED BY ‘password‘;
OR
CREATE USER ‘native‘@‘127.1.1.1‘ IDENTIFIED BY ‘password‘;
修改用户的密码:
ALTER USER ‘native‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘new_password‘;
OR
ALTER USER ‘native‘@‘localhost‘ IDENTIFIED BY ‘new_password‘;
查看当前有多少用户:
Select user, host from mysql.user;
给用户native分配可以对所用数据库的所有表进行操作的权限,并设置口令为123
grant all privileges on *.* to native@localhost identified by '123';
给用户native的数据库vtdc的employee表 分配 select insert, update, create and drop 的权限,并设置口令为123
grant select,insert,update,delete,create,drop on vtdc.employee to native@localhost identified by '123';
直接向mysql.user表插入记录:
insert into user (host,user,password) values ('127.1.1.1','Testuser',password('jss'));
直接修改mysql.user表的用户口令:
update mysql.user set password=password('new_password') where User="Testuser" and Host="localhost
使用mysqladmin修改用户的密码:
mysqladmin -u ative@localhost -p old_password password new_password;
使用set password 语句修改密码:
set password for 'native'@'localhost' = password('new_password');
删除用户
drop user native@localhost;
or
delete from user where user='native' and host = 'localhost';
取消授权用户:
REVOKE privilege ON databasename.tablename FROM 'username'@'host';、
e.g.: revoke select on test.user from 'native'@'localhost';
查看数据目录地址
show variables like 'datadir';