mysql5.7建立新用户

一、登录root用户;mysql

二、建立新用户,若是是限制本地访问,使用@localhost;若是容许远程访问,使用@%。这里建立一个本地用户。sql

mysql> create user 'litemall'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)数据库

三、此时用户建立成功,但没有任何库的权限,须要进行受权;ide

查看当前数据库    show databases;.net

若是受权库为新库,则建立数据库    create database litemall;get

受权    string

mysql> grant all privileges on litemall.* to 'litemall'@'localhost' identified by '123';
Query OK, 0 rows affected, 1 warning (0.00 sec)it

刷新系统权限表io

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)date

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

修改密码

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)

相关文章
相关标签/搜索