To be a better coder
分类: LINUX
2020-04-03 14:47:53
https://www.cnblogs.com/yiwd/p/5534232.html 1.查看所有数据库容量大小 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;2.查看所有数据库各表容量大小 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 order by data_length desc, index_length desc;3.查看指定数据库容量大小
例:查看mysql库容量大小
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 where table_schema='mysql';4.查看指定数据库各表容量大小
例:查看mysql库各表容量大小
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='mysql' order by data_length desc, index_length desc;https://www.cnblogs.com/dekevin/p/10276832.html
今天更新数据库,同事给发来个20M的psc文件,这是数据库备份文件,从这个备份文件里提取了200M 的sql文件,然后运行了这个sql文件,然后就出现了标题的错误
[Err] 2006 - MySQL server has gone away
这是因为sql文件太大了,把mysql安装目录下的my.ini文件中的 max_allowed_packet=***M,这个*** 是个数字,要大于你的sql文件大小。我的sql文件200M,我把这个改成了max_allowed_packet=300M ,再运行sql,运行完毕没有报错。
运行sql文件恢复备份出错[Err] Cannot add or update a child row: a foreign key constraint fails
mysql添加外键失败,这是因为要添加的外键和表中的主键不匹配,这个我是和 MySQL server has gone away 一起出现的,这就好理解了。直接重新运行了sql文件搞定。
解决的过程就是:删除所有表数据,重新创建表,重新插入数据。当然这个过程都是运行sql文件自动执 行的。
————————————————
版权声明:本文为CSDN博主「wxx_csdn」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wxx_csdn/java/article/details/78675178