新建用户:
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("12345678"));
用户授权:
mysql>grant all privileges on *.* to test@localhost identified by '12345678';//第一种情况:所有权限
mysql>grant select,delete,update,create,drop on test.* to test@"%" identified by "12345678";//第二种情况:部分权限
mysql>flush privileges;//刷新系统权限表
(授权格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";)
root用户忘记密码:
vi /etc/my.cnf
[mysqld]
skip-grant-tables