foreword
那么这里博主先安利一下一些干货满满的专栏啦!
Linux column https://blog.csdn.net/yu_cblog/category_11786077.html?spm=1001.2014.3001.5482 Operation system column https://blog.csdn.net/cblog/category_1 2165502.html? SPM = 1001.2014.3001.5482 hand tore data Structure https://blog.csdn.net/yu_cblog/category_11490888.html?spm=1001.2014.3001.5482
migration steps
1. On the source server, use the mysqldump command to export the data and structure of the entire database into a .sql file
mysqldump -u username -p --all-databases > alldb.sql
Of course, the path of our alldb.sql can be changed by ourselves, so that it is written in the current path by default
Among them , username represents the user name for logging in to mysql, if it is root , write root
--all-databases is an option of mysqldump , which means backing up all databases
If you only want to back up a specific database, use the --databases option, where db1/db2/db3 is the name of the database to be backed up.
mysqldump -u username -p --databases db1 db2 db3 > databases.sql
2. Copy the exported SQL file from the source server to the target server
Use the scp command to transfer files
scp alldb.sql user@target_server:/path/to/destination
Represents sending the alldb.sql file in the current path to the target_server
target_server represents the target server ip
user represents the target server login user
/path/to/destination represents the storage location of alldb.sql sent in the past (absolute path)
3. On the target server, use the mysql command to import the data and structure in the SQL file into the new MySQL server
mysql -u username -p < /path/to/alldb.sql
-user represents the login user of mysql
/path/to/alldb.sql represents the absolute location of alldb.sql on the target server
Note that you need to install and configure a MySQL server on the target server before importing data. You should also make sure to use the same MySQL version on the destination server as the source server to ensure compatibility during the import process.