导出指定表
mysqldump --no-create-info -uroot -proot test book book_chapter book_chapter_item > book.sql
导出数据库,排除某几个表
/usr/local/mysql/bin/mysqldump -uroot -proot --ignore-table=shiji.log shiji > /data/shiji/db/shiji.sql
统计所有库大小
SELECT
table_schema AS '数据库',
sum(table_rows) AS '记录数',
sum(truncate(data_length/1024/1024, 2) ) AS '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2) ) AS '索引容量(MB)'
FROM information_schema.TABLES
GROUP BY table_schema
ORDER BY sum(data_length) desc, sum(index_length) desc;
查看某个库的所有表大小
SELECT
table_schema AS '数据库',
table_name AS '表名',
table_rows AS '记录数',
truncate(data_length/1024/1024, 2) AS '数据容量(MB)',
truncate(index_length/1024/1024, 2) AS '索引容量(MB)'
FROM information_schema.TABLES
WHERE table_schema = 'test'
ORDER BY data_length desc, index_length desc;
查看某个表大小
SELECT table_name,
round(data_length/1024/1024, 2) AS '数据容量',
round(index_length/1024/1024, 2) AS '索引容量(MB)'
FROM information_schema.TABLES
WHERE table_schema = 'test' AND table_name = 'log';
授权多个IP
GRANT ALL PRIVILEGES ON *.* TO 'aishu'@'192.168.80.80,192.168.81.150' IDENTIFIED BY 'test';
创建账号
create user 'test2'@'%' identified by 'dbname@tt';
grant all privileges on dbname.* to 'test2'@'%';
ALTER USER 'test2'@'%' IDENTIFIED WITH mysql_native_password BY ''dbname@tt';