创建snort数据库,创建snort用户,将snort库所有表的所有权限赋予用户snort。
mysql> create database snort;
Query OK, 1 row affected (0.06 sec)
创建数据库
mysql> use mysql;
进入mysql库
创建用户,设置初始密码 (创建tem用户,并给stu数据库赋权)
flush privileges使改动生效;注:如果不执行该指令,则无法正常执行后续指令。
mysql> grant all on snort.* to 'snort'@'localhost' ;
Query OK, 0 rows affected (0.00 sec)
将snort库的所有权限赋予snort用户(给数据库已存在的用户snort赋予权限;@'%' 给任意一台机器,@'localhost'给本地机器,@'IP地址',给指定IP)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使改动生效
赋予root所有数据库的权限
从上面概括得出
grant 权限 on 数据库名.数据库表名 TO 用户名@电脑IP(所有电脑则为%)identified by 密码
mysql> show grants for snort@localhost;
+-------------------------------------------------------------------------------------+
| Grants for snort@localhost |
+-------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'snort'@'localhost' IDENTIFIED BY PASSWORD '1e6b29186dd45e97' |
| GRANT ALL PRIVILEGES ON `snort`.* TO 'snort'@'localhost' |
+-------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';