一、登錄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)