创建snort数据库,创建snort用户,将snort库所有表的所有权限赋予用户snort。
mysql> create database snort;
Query OK, 1 row affected (0.06 sec)
创建数据库
mysql> create user user01;
Query OK, 1 row affected (0.06 sec)
创建用户snort
mysql> use mysql;
进入mysql库
mysql> insert into user (Host,User,Password) values ("localhost","user01",PASSWORD("123456"));
报错: ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
正确的添加用户方法:
mysql> GRANT USAGE ON *.* TO 'user01'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
(用户:user01,密码:123456,这样就添加了一个新的用户,不会出以上的错误了)
(看是否让所有远端都可以连接数据库-使用 % 代替 localhost)
GRANT USAGE ON *.* TO 'user01'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
再执行:
mysql> SET PASSWORD FOR user01@'localhost' = PASSWORD('123456');
mysql> flush privileges;
最后:
mysql> grant all on snort.* to 'user01'@'localhost' ;
Query OK, 0 rows affected (0.00 sec)
将snort库的所有权限赋予 user01用户
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使改动生效
重启 使用用户登录:
mysql -uuser01 -p
......OK了!