查看连接数
show processlist; 也可以查information_schema.processlist表
查看定义/默认的参数
show variables like ‘%参数名字%‘;
取消用户权限:
revoke SELECT, EXECUTE, SHOW VIEW ON `tsdp`.* from ‘tsdp_ro‘@‘10.58.%.%‘ ;
更改参数
set session 参数名字=值;
set global 参数名字=值;
查看状态值
show global status;
show status like ‘%参数名字%‘;
查看同步状态
show slave status\G 做主从同步 change master to.....
创建用户/赋予权限
create user [email protected]‘111.111.111.111‘ identified by ‘123456‘;
grant all on clus.* to [email protected]‘111.111.111.111‘;
查看触发器
use clus;
show triggers;
show create trigger triggername; 可以在information_schema.trigger差看
查看存储过程
use clus;
show procedure status;
show create procedure procedurename;
查看event
use clus;
show events;
show create event eventname;
建库
CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
添加字段
alter table tablename add column name varchar(10);
添加自增主键字段
alter table tablename add column `ID` int primary key auto_increment;
修改字段类型
alter table tablename modify column name varchar(10);
删除字段
alter table tablename drop clumn name;
索引
alter table tablename add index index_name (字段);
alter table tablename drop index index_name;
create index index_name on tablename(字段);
drop index index_name on tablename;
主键
alter table tablename add primary key (`ID`) auto_increment;
1.alter table tablename modify column `ID` int
2.alter table tablename drop primary key (`ID`);
锁库备份
/usr/local/mysql/bin/mysqldump -uroot -p‘vxxx‘ -h127.0.0.1 -P3306 --databases 库名 --lock-all-tables --master-data > axx_20130607.sql 不锁就去掉--lock-all-tables --master-data
错误链接过多,mysqld中断主机所有请求,恢复可请求状态
mysqladmin flush-hosts
查看用户资源限制情况
select Host,User,Password,max_questions,max_updates,max_connections,max_user_connections from mysql.user;
转换Myisam引擎到Innodb
alter table your_table_name engine=‘Innodb‘;
查看是否有使用Myisam引擎的表结构
select * from information_schema.tables where TABLE_SCHEMA not in (‘mysql‘,‘information_schema‘,‘performance_schema‘) and engine != ‘InnoDB‘;
导出表结构
mysqldump -u*** -p -d your_database_name > database_structure.sql
查看user权限
show grants for [email protected]‘127.0.0.1‘;
为一个用户修改权限
UPDATE mysql.user SET Grant_priv=‘Y‘, Super_priv=‘Y‘ WHERE User=‘root‘;
FLUSH PRIVILEGES;
mcluster限制检查sql
|
源数据库mysql特性统计
|