Effortless MySQL: Import and Export Databases

To import a database using MySQL, follow these steps:

  • Open a terminal or command prompt.
  • Navigate to the directory where the database dump file (usually with a .sql extension) is located.
  • Ensure that MySQL is installed and running on your system.
  • Run the following command to import the database:
mysql -u username -p database_name < dump_file.sql

Replace username with your MySQL username, database_name with the name of the database you want to import the data into, and dump_file.sql with the actual name of your dump file.

  • When prompted, enter your MySQL password. Note that while typing the password, it won't be visible on the screen.
  • Wait for the import process to complete. Depending on the size of the database, this may take some time.

To extract (or export) a database using MySQL, use the following command:

mysqldump -u username -p database_name > dump_file.sql

Replace username with your MySQL username, database_name with the name of the database you want to export, and dump_file.sql with the desired name for the dump file.

When prompted, enter your MySQL password. The command will create a new file named dump_file.sql in the current directory, containing the SQL statements necessary to recreate the database structure and data.

Remember to replace username, database_name, and dump_file.sql with the appropriate values based on your setup.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to restrict direct root access in Linux

We can do it just in two steps. Step One: At first we will create new root user as follows (for...

How to extract .tar.gz files in Linux/UNIX OS

A tarball is a group of files that are bundled together using the tar command. Use the...

How to add welcome message when SSH start?

You need to change the contents of /etc/motd. Unfortunately, by default, /etc/motd is a link to...

How to change root password when SSH logged in

Run the following command: passwd Now type your new passwordOnce done, retype new passwordDone!...

How to install Pinguzo on any Linux/UNIX OS

Login to Pinguzo panel using Softaculous account or create an account of Pinguzo To add new...