zjp0633 发表于 2018-10-7 11:25:34

MySQL常用语句命令

MySQL常用语句命令
  修改root密码
  SET PASSWORD FOR 'root'@'localhost' =PASSWORD('newpass');
  创建数据库:
  create database cacti;
  新增客户并赋予权限
  grant all on cacti.* to cacti@localhostidentified by “cacti”;
  刷新权限
  flush privileges;
  导入数据
  mysql –uroot –p cacti use mysql
  >update user set Update_priv ='Y' whereuser = 'root';
  查看临时表
  show variables like "%tmp%";
  设置全局临时表大小
  setglobal tmp_table_size=33554432;
  修改MySQL远程连接权限
  grant all privileges on *.* to 'root'@'%'identified by "123" with grant option;
  显示当前用户权限
  show grants for root@'localhost';
  备份数据库
  mysqldump -uroot -p   --database
  慢查询日志分析
  开启慢查询
  log-slow-queries=/var/log/mysqld-slow.log
  long_query_time=2
  //dbquery-slow
  query_time 查询时间
  lock_time锁表时间
  rows_send查询返回行数
  rows_examind所有查询的行数
  timestamp 时间戳
  查看当前数据库的表空间管理类型
  show variables like"innodb_file_per_table";
  innodb_file_per_table=1 为使用独占表空间
  innodb_file_per_table=0 为使用共享表空间
  ON代表独立表空间管理,OFF代表共享表空间管理;


页: [1]
查看完整版本: MySQL常用语句命令