一、创建MySQL数据库
mysql> CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;Query OK, 1 row affected
二、创建用户
2.1、新建用户
mysql> create user 'test'@'%' identified by 'test';Query OK, 0 rows affected
2.2、查询用户
mysql> select user,host from mysql.user;+---------------+-----------+| user | host |+---------------+-----------+| flash_sale | % || root | % || test | % || thoughts-beta | % || mysql.session | localhost || mysql.sys | localhost || root | localhost |+---------------+-----------+7 rows in set
2.3、删除用户
drop user test@'%';
2.4、更新密码
mysql> set password for test = password('123456');Query OK, 0 rows affected
·
2.5、分配用户权限
mysql> grant all privileges on testdb.* to 'test'@'%' identified by 'test';Query OK, 0 rows affected
2.6、查看用户权限
mysql> show grants for test;+--------------------------------------------------+| Grants for test@% |+--------------------------------------------------+| GRANT USAGE ON *.* TO 'test'@'%' || GRANT ALL PRIVILEGES ON `testdb`.* TO 'test'@'%' |+--------------------------------------------------+2 rows in set
三、测试
