• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / MySQL Tutorial (create,connect database, update tables, export etc) Documentation & TIPS / mysql import export database command line linux ubuntu debian wamp xamp

mysql import export database command line linux ubuntu debian wamp xamp

Here are the MySQL import and export commands for Linux via the command line:


Import SQL Files to MySQL Database Using Command Line

Table of Contents

Toggle
    • Export a MySQL Database (Dump)
      • Options:
      • Example:
    • Import a MySQL Database
      • Example:
      • If the Database Does Not Exist:
    • Export & Import with Compression
      • Export (Dump & Compress)
      • Import (Decompress & Restore)
    • Export & Import Specific Tables
      • Export a Specific Table
      • Import a Specific Table
    • List All Databases
      • Bonus windows server
    • 2. Import Files Using WAMP MySQL CLI
  • 3. Import Files Using XAMPP MySQL CLI

Export a MySQL Database (Dump)

To export (dump) a MySQL database to a .sql file, use:

mysqldump -u [username] -p [database_name] > backup.sql

Options:

  • -u [username] → MySQL username
  • -p → Prompt for password
  • [database_name] → Name of the database to export
  • backup.sql → Output file containing the SQL dump

Example:

mysqldump -u root -p mydatabase > mydatabase_backup.sql

Import a MySQL Database

To restore/import a MySQL database from a .sql file:

mysql -u [username] -p [database_name] < backup.sql

Example:

mysql -u root -p mydatabase < mydatabase_backup.sql

If the Database Does Not Exist:

Create it first:

mysql -u root -p -e "CREATE DATABASE mydatabase;"
mysql -u root -p mydatabase < mydatabase_backup.sql

Export & Import with Compression

For large databases, use gzip to compress the export:

Export (Dump & Compress)

mysqldump -u root -p mydatabase | gzip > mydatabase_backup.sql.gz

Import (Decompress & Restore)

gunzip < mydatabase_backup.sql.gz | mysql -u root -p mydatabase

Export & Import Specific Tables

Export a Specific Table

mysqldump -u root -p mydatabase table_name > table_backup.sql

Import a Specific Table

mysql -u root -p mydatabase < table_backup.sql

List All Databases

Before importing/exporting, you can list databases using:

mysql -u root -p -e "SHOW DATABASES;"

Bonus windows server

2. Import Files Using WAMP MySQL CLI

C:\wamp64\bin\mysql\mysql8.0.27\bin\mysql -u username -p database_name < path_to_mysql_file.sql

3. Import Files Using XAMPP MySQL CLI

C:\xampp\mysql\bin>mysql -u username -p database_name < path_to_mysql_file.sql

Primary Sidebar

MySQL Tutorial (create,connect database, update tables, export etc) Documentation & TIPS

  • mysqldump import /export mysql database command line, phpmyadmin, Cpanel, mysql workbench, xamp
  • mysql commands
  • phpmyadmin install / configure on nginx ubuntu 20.04 apache2 debian 10
  • improve mysql performance wordpress my.cnf file configuration
  • innodb buffer pool size measure & adjust by pages, read requests etc
  • mysql workbench tutorials (Sql Development , modelling, server admin export & import)
  • mysql errors
  • Innodb vs myisam (table engines row lock vs table lock)
  • mysql max connections limit check increase how to decide thread cache size
  • MySQL innodb memory allocation & usage calculation
  • MySQL query cache vs redis vs memcached buffer pool database cache
  • mysql 8 installation on ubuntu 20.4
  • mysql configuration file location linux , windows , mac
  • mysql root password change reset update set A-Z info
  • mysql user creation, password , grant permissions user management guide
  • mysql slow query log enable disable set query time ideal mysql long query time
  • mysql access denied for user 'root'@'localhost' (using password yes) no Error 1045
  • monitoring mysql with new relic
  • mysql restart ubuntu status start stop in linux windows reload
  • mysql open_files_limit increase to raise open file cache table definition cache
  • mysql memory limit setting increase or decrease allocation
  • mysqltuner installation suggestions
  • mysql auto backup ubuntu 22.04 using automysqlbackup
  • mysql high cpu usage cases and limiting cpu usage
  • mysql oom killer
  • mysql memory parameters
  • check mysql database size and table size
  • mysql find replace wordpress posts content
  • mysql import export database command line linux ubuntu debian wamp xamp
  • mysql interview questions and answers fresher to experience

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy