homesourcenvt

MySQL

Docs

Commands

MySQL 查询状态

mysql> show processlist;

各状态含义

配置访问权限

GRANT ALL PRIVILEGES ON *.* TO 'user'@'ip' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
use mysql;
SELECT user, host, password FROM user where host = 'ip';
delete from user where user = 'user';
flush privileges;

备份 master 数据库

MySQL :: MySQL 5.7 Reference Manual :: 16.3.1.3 Backing Up a Master or Slave by Making It Read Only

mysql -uroot -ppassword --database=database -e "FLUSH TABLES WITH READ LOCK; SET GLOBAL read_only = ON;"
mysql -uroot -ppassword --database=database -e "show master status\G" > master-status-beforedump.txt
mysqldump -uroot -ppassword database | gzip > database.sql.gz
mysql -uroot -ppassword --database=database -e "show master status\G" > master-status-afterdump.txt
mysql -uroot -ppassword --database=database -e "SET GLOBAL read_only = OFF; UNLOCK TABLES;"

查询包含时间戳的字段

sql - Convert timestamp to date in MySQL query - Stack Overflow

Cluster

Resources