MySQL Import Export Guide
Data can be imported and exported in MySQL using either the command line tools or MySQL client. Here is how to do it using the command line tool:
- Export data:
mysqldump -u [username] -p [database_name] > [filename].sql
This command will export all data from the database into a .sql file, and you can specify a password using the -p parameter. If the password is empty, you do not need to input anything.
- Import data:
mysql -u [username] -p [database_name] < [filename].sql
This command will import data from the .sql file into the specified database.
Additionally, you can also use the MySQL client to import and export data. Use the source command to import .sql files in the MySQL client, and use the SELECT … INTO OUTFILE command to export data to a file.