上午
1 、环境准备
2 、安装 mysql 绿包
3 、配置 mysql 工作环境
mysql -hip 地址 -p3306 -uroot -p (远程连接使用)
4 、 mysql 基础命令
( 1 )修改密码
( 2 )授权远程登录
( 3 )刷新
( 4 )查看表结构
( 5 )查看用户与主机关系
5 、 mysql 操作命令
( 1 )创建 li 用户
( 9 )查看表内容
下午
1 、脚本安装 mysql
2 、 mysql 命令回顾
( 1)远程登录前提条件是 mysql.user 表中的 host 属性为 % ,如果是 localhost 就不允许远程登录,
3 、 mysql 用户权限设置
( 1 )创建 lilaosi 用户
mysql> create user 'lilaosi'@'%' identified by 'Lilaosi@123456'; // 添加
lilaosi 账号
( 2 )修改密码
mysql> alter user 'lilaosi'@'%' identified by 'Lilaosi@123456'; // 修改密码
4 、命令练习
( 1 )创建三个账号, abc[abcd] , ccc[a1b2c3],ddd[231343]
mysql> create user 'abc'@'%' identified by 'abcd';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'ccc'@'%' identified by 'a1b2c3';
Query OK, 0 rows affected (0.01 sec)
mysql> create user 'ddd'@'%' identified by '231343';
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user from mysql.user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | aaa |
| % | abc |
| % | ccc |
| % | ddd |
| % | li |
| % | lilaosi |
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
11 rows in set (0.00 sec)
( 2 )删除用户 lilaosi
删除 lilaosi 用户
mysql> drop user 'lilaosi';
Query OK, 0 rows affected (0.02 sec)
mysql> select host,user from mysql.user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | aaa |
| % | abc |
| % | ccc |
| % | ddd |
| % | li |
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
10 rows in set (0.00 sec)
( 3 ) aaa , ccc , ddd 三个账户的密码修改为 123
mysql> alter user 'aaa'@'%' identified by '123';
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'ccc'@'%' identified by '123';
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'ddd'@'%' identified by '123';
Query OK, 0 rows affected (0.01 sec)
( 4 )权限添加练习
( 1 )添加 aaa 账户,设置密码 aaaa
mysql> create user 'aaa'@'%' identified by 'aaaa';
Query OK, 0 rows affected (0.01 sec)
( 2 )使用 aaa 账户访问 mysql 服务
root@mysql \~\]# mysql -uaaa -paaaa ( 3 )查看 test 数据库发现没有权限 mysql\> show databases; +--------------------+ \| Database \| +--------------------+ \| information_schema \| \| performance_schema \| +--------------------+ 2 rows in set (0.00 sec) ( 4 )退出并使用 root 账户登录 mysql\> quit Bye \[root@mysql \~\]# mysql -uroot -pRoot@123456 ( 5 )为 aaa 账户添加查看 test.user 表的权限 mysql\> grant select on test.user to 'aaa'; Query OK, 0 rows affected (0.00 sec) ( 6 )退出 root ,使用 aaa 账户登录 mysql\> quit Bye \[root@mysql \~\]# mysql -uaaa -paaaa ( 7 )查看数据库,查看表,查看表内容,能够正常查看    ( 14 )为 aaa 用户一次性添加 delect , update 权限 mysql\> grant delete,update on test.user to 'aaa'; Query OK, 0 rows affected (0.00 sec) mysql\> show grants for 'aaa'; +--------------------------------------------------------------------+ \| Grants for aaa@% \| +--------------------------------------------------------------------+ \| GRANT USAGE ON \*.\* TO \`aaa\`@\`%\` \| \| GRANT SELECT, INSERT, UPDATE, DELETE ON \`test\`.\`user\` TO \`aaa\`@\`%\` \| +--------------------------------------------------------------------+ 2 rows in set (0.00 sec) **6** **、权限角色** **(** **1** **)创建角色** mysql\> create role 'jingli'; // 创建 jingli 角色 Query OK, 0 rows affected (0.00 sec) mysql\> create role 'yuangong'; // 创建 yonghu 角色 Query OK, 0 rows affected (0.00 sec)      