MySQL新加用户和开启慢查询

mysql>grant select on *.* to read@'%' identified by 'j';  //给予read用户只读全部库的权限

mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";  //test用户对所有数据库都有select,delete,update,create,drop 权限。

mysql>flush privileges; //刷新系统权限表

//@"%" 表示对所有非本地主机授权,不包括localhost。

//对localhost授权:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。

格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";

开启慢查询my.cnf 加入下来代码

slow_query_log=1   //开启慢查询
long_query_time=1  //超过1s记录
slow_query_log_file=/usr/local/mysql/slowquery.log  //记录的log文件地址

  

  GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.60.17' IDENTIFIED BY 'cc.123' WITH GRANT OPTION;

  执行上面命令还是不能远程连接

  GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.60.17' IDENTIFIED BY 'cc.123';

  再执行上面的命令,就可以用客户端连接了!

  SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

  给与授权权限:

     GRANT  USAGE ON  *.* TO 'root'@'%' WITH GRANT OPTION;

SET  GLOBAL slow_query_log=ON
SET  long_query_time=4;