Exporting and Importing .sql Files from Command Line with Customization
Exporting and importing .sql files via command line is a convenient way to manage MySQL databases. This capability provides flexibility and support for specific requirements during the export and import process.
MySQLdump for Exporting Data:
To export a database, use the mysqldump command:
mysqldump -u [username] -p [database_name] > [filename].sql
MySQL for Importing Data:
For importing a .sql file, execute the following:
mysql -u [username] -p -h [hostname] [database_name]Customizing Export and Import Options
Export Options:
Import Options:
Example Command:
To export the 'blog' database without data and disable foreign key checks:
mysqldump -u vivek -p blog --no-data --foreign-key-checks=0 > blog_structure.sql
To import the 'data.sql' file into the 'blog' database, replace existing data, and ignore the 'users' table:
mysql -u vivek -p blog --replace --ignore-table=usersBy utilizing these options, administrators can tailor the export and import process to meet specific requirements, enhancing the efficiency and flexibility of database management from the command line.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3