Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problems encountered in Mysql import and export

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to solve the problems encountered in Mysql import and export. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Background

Since I converted all the tasks at hand to docker operation and management, I encountered a series of holes, this time the problem of mysql backup.

The reason is that-v is not specified when starting mysql mirroring, resulting in a large docker after a period of time, the original disk is not enough, and need to be migrated to a new disk.

There are some problems when using import and export, which waste a lot of time to solve.

Solution process

Locate the mysql image is too large

View the space occupied by the container

```docker system df```

View details

Local Volumes space usage:VOLUME NAME LINKS SIZE3e764b0633ea2c3f3dc5b0bf79dc753055d7c09451b477d3015650c66ea4a5fb 0 0B598a592e1f9d90d2564c7c52f45f6f6a96784ad0426ec60682299fa1a1b93b96 0 0B5eb12b3b0091810bbe3c94c5801ad2f2ff51d79b69b0ac01eb37cf00d37d89f6 0 0Badmin_logs 0 0Bf42e3ef90e4c7b3658a0fb4a877e90b298b12cb58cd63f38d9b4ad5c2ab41d73 0 0B3361b9c615e09708170018dc7d170b8d4b498dd83cbcb155a3d41234d08e8119 1 9.3G

According to the information returned above, only two containers have VOLUMES, one is mysql and the other is redis, so use the docker inspect container_id command to check the specific information of the specific container and find that it is indeed the 9.3G Volume.

CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE cb76bbc211e6 mysql "docker-entrypoint.s..." 1 7B

Backup mysql to a newly mounted disk

````docker exec-it mysql mysqldump-u username-p password database > / mnt/vdb/data/mysql/test_ db.sql``username, password and database are modified by themselves

Import mysql

1. To ensure that the previous data is still there, set up another mysql container and map to the host using-v.

two。 Then execute: docker exec-i mysqld mysql-uroot-proot federation

< /mnt/vdb/data/mysql/fed_db.sql 错误来了 ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump: [Warning] Using a password on the command line interface can be insec' at line 1 我搜索了很多的资料,都没有效果,于是决定使用图形化工具直接备份,于是使用navicat,备份,在新的镜像导入,并且导入成功。 这个里面的Rows,和我导入之后的显示的不一样 这个里面的Rows,和我导入之后的显示的不一样 这个里面的Rows,和我导入之后的显示的不一样

WTF? The total is 1688, showing only 1480?

Enter the docker container and use the command line query. It is indeed 1688, and the Rows displayed is not correct, So....

Summary

When using docker, it is necessary to consider whether external volumes are needed. In general, the database had better be external, and backup and migration are very convenient.

Don't rely too much on the GUI of the database, the command line is the most reliable

Really not, you add a hard drive, anyway, it is all on the server, but to make sure that the server will not jump, otherwise the data is easy to lose.

Thank you for reading! On "how to solve the problems encountered in Mysql import and export" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report