mysql 5.7 创建新用户_mysql5.7创建新用户

1、登陆root用户;

2、创建新用户,如果是限制本地访问,使用@localhost;如果允许远程访问,使用@%。这里创建一个本地用户。

mysql> create user 'litemall'@'localhost' identified by '123';

Query OK, 0 rows affected (0.00 sec)

3、此时用户创建成功,但没有任何库的权限,需要进行授权;

查看当前数据库    show databases;

如果授权库为新库,则创建数据库    create database litemall;

授权

mysql> grant all privileges on litemall.* to 'litemall'@'localhost' identified by '123';

Query OK, 0 rows affected, 1 warning (0.00 sec)

刷新系统权限表

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

这样,一个用户的权限就建立了。

修改密码

mysql> update user set authentication_string=password('litemall123456') where User='litemall' and Host='localhost';

Query OK, 1 row affected, 1 warning (0.03 sec)

Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


版权声明:本文为weixin_31319027原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。