以下两点代码都是实现同样的功能:
1.创建一个名为snort的数据库。
2.将snort数据库导入到create_mysql。
3.对IP地址为localhost上的snort数据库创建一个用户为snort,密码为:“MYSQLSNORTPASSWORD”。
4.对snort数据库里面的表格给予用户snort增删改差的权限。
代码一:
$ mysql -u root -p
mysql> create database snort;
mysql> use snort;
mysql> source ~/snort_src/barnyard2-2-1.13/schemas/create_mysql
mysql> CREATE USER 'snort'@'localhost' IDENTIFIED BY 'MYSQLSNORTPASSWORD';
mysql> grant create, insert, select, delete, update on snort.* to 'snort'@'localhost';
mysql> exit
代码二:
echo "create database snort;" | mysql -u root -p
mysql -u root -p -D snort < ~/snort_src/barnyard2-master/schemas/create_mysql
echo "grant create, insert, select, delete, update on snort.* to snort@localhost identified by 'MYSQLSNORTPASSWORD'" | mysql -u root -p
注:source = \.