MySQL import and export backup

MySQL import and export backup

Today, I backed up the database, and I found many commands on the Internet, but found that it didn't work. So try the following command by yourself and it can be executed correctly after testing.


// 导出命令
mysqldump db > mydb.dmp -u root -p

// 导入命令
mysql -uroot -p dbtarget < mydb.dmp

        These two commands can import and export dmp format or SQL format, only need to modify the corresponding file suffix name.

        Check the difference, it should be the order of the command parameters. When exporting, the database connection-related commands are later, and when importing, the database-related connection commands are first.

The connection related commands are as follows (commonly used):

-uxxx //用户名
-hxxx //host
-pxxx //端口
-pxxx //密码,也可以不指定,会提示输入

Guess you like

Origin blog.csdn.net/polixiaohai/article/details/105970749