mysqldump - MySQL: How to export and import an .sql file from command line? -


I want to export and import a .qq file from a MySQL database and from the command line.

Is there a command to export the SQL file in MySQL? How can I import it?

While importing, there may be obstacles like enabling / disabling external key checks / exporting only table structure.

Do we give those options to mysqldump ?

to export

if it is complete DB, then:

  $ mysqldump -u [onename] -p [pass] db_name & gt; Db_backup.sql   

If this is all DB, then:

  $ mysqldump -u [onename] -p [pass] - all databases & gt; All_db_backup.sql   

If there are specific tables within DB:

  $ mysqldump -u [uname] -p [pass] db_name table1 table2 & Gt; You can also go while auto-compacting the output using gjip (if your DB is too large):  
  $ mysqldump -  you [akaam] -p [ Near] DB_NA | Jizip & gt; Db_backup.sql.gz   

If you want to remotely access it and you have access to the server in question, the following will work (the MySQL server believes the 3306 is on the port) : $ mysqldump-P 3306-h [ip_address] -u [onename] -p [pass] db_name & gt; To import the SQL data file, type the following command:

  $ mysql - db_backup.sql   

to import

U username -p -h localhost data-base-NAME & lt; Data.sql

In this example, import the 'data.sql' file into the 'blog' database using sat as the user name:

  $ mysql -u sat -p -h localhost blogs & lt; Data.sql   

If you have a dedicated database server, replace the local host hostname with the actual server name or IP address as follows:

  $ Mysql -u user name-p-h 202.54.1.10 database name & lt; Data.sql   

or host name like mysql.cyberciti.biz

  $ mysql -u username-p -h mysql.cyberciti.biz database- Name & lt; Data.sql   

If you do not know the name of the database or the name of the database is included in the SQL Dump, then you can do something like this:

  $ Mysql -यू usernames-p-H202.54.1.10 & lt; Data.sql   

Reference:

If you want a GUI tool, you can probably use

Comments