Last active
February 19, 2020 03:45
-
-
Save 1901/322874986745632f5b215f5724005dac to your computer and use it in GitHub Desktop.
[MySQL commands] #linux #mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 创建只读账号 (% 表示不限制 IP 登录) | |
| GRANT SElECT ON *.* TO 'reader'@'%' IDENTIFIED BY "password"; | |
| -- 查看 test 数据库下每张表的大小 | |
| SELECT TABLE_NAME, DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES where TABLE_SCHEMA='test'; | |
| -- Export database schema | |
| mysqldump -u user -p -h host --no-data dbname > dbname_schema.sql | |
| -- 备份数据库并打包成 gz 格式 | |
| mysqldump -u user -p password -h host --databases dbname --ignore-table=schema.table | gzip > dump.sql.gz | |
| -- 导入 gzip 压缩的数据库 | |
| gunzip < dump.sql.gz | mysql -u user -p password -h host | |
| -- 显示已被打开的表 | |
| show open tables where in_use>0; | |
| -- 当前正在处理的列表 | |
| show processlist; | |
| -- check max_connections | |
| SELECT @@max_connections; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment