我的mysql命令记录

以下命令在 mysql>提示符下

select version(),current_date;

show processlist;

show status;

show status like "uptime%";

show grants;

show grants for 'admin'@'localhost';

show variables;

show engines;

show variables like "chara%";

show characeter set;


show slave status \G;

show privileges;

show logs;

show engine bdb logs;

show warnings;

show errors;

show index from table;


select host,user,password from mysql.user;

create database data1;

create database data2 default character set gb2312;

show create database data2;

show create table data2;

grant all on data2.* to data2@localhost identified by "123456";

grant all on data2.* to data2@"%" identified by "123456";

grant all on *.* to admin@"%" identified by "123456" with grant option;



source /opt/back/data2.sql; #导入备份的数据库

shell# mysql -uroot -p < /opt/back/data2.sql #导入备份的数据库

shell#mysqldump -uroot -p data2 > /opt/back/data2.sql #导出数据库

shell#mysqldump -uroot -p --default-character-set=gb2312 data2 > /opt/back/data2.sql

flush tables with read lock;

grant usage on *.* to abc@localhost;#abc账户只能有登陆权限,连接,没有其他权限,

DELETE FROM mysql.user WHERE User = '';
DELETE FROM mysql.user WHERE Host='localhost' AND User='';


drop user 'user'@'host';


show plugins;

show variables like 'have_ndbcluster';#看是单机还是集群

show variables like 'log%';

6、查看Mysql当前有哪些触发器和存储过程

mysql> show triggers;
mysql> show procedure status;



mysql的数据备份操作

主从配置。主库服务,从库用来备份。

全备份选择在服务器压力最小的时间段。

增量备份根据实际情况作每小时一次,每天或者每周一次全备份

备份文件同步到备份盘柜上。

1.最简单的可以写脚本来做
通过调用mysqldump,mysqlhotcopy命令
dump会锁表,hotcopy不锁表
当库比较大,比如几十G的时候,不再合适。

2 LVM 做数据分区快照
3开源备份工具 XtraBackup
4商业备份工具 InnoDB hotbackup

5冷备,停止服务,直接备份数据文件所在目录。
 

你可能感兴趣的:(数据库,mysql,命令,记录,休闲)