Emilio J. Gomez
Buscar en moleculax
How to Export & Import All MySQL Databases


How to Dump All Databases from MySQL via Command Line

The simplest way to dump all databases from MySQL into a .sql file, for backup or migration or otherwise, is using the –all-databases flag like so:
mysqldump --all-databases > all_databases_dump.sql
Because this command exports all databases, there is no need to specify a database name. All databases stored in mySQL will be dumped into the “all_databases_dump.sql” export file in the present working directory.
If need be you can also specify a username and password when dumping all databases like so, in this case with the username being root:
mysqldump -u root -p --all-databases > all_databases.sql
After the mysql database has been dumped, my personal preference is to create a tar gzip from it as described here but that’s entirely optional.

How to Export a Specific Database from MySQL

If you do want to dump a specific database by name rather than export all databases, that is equally as simple:
mysqldump database_name > database_name_dump.sql
The mysqldump command has many parameters and flags which can be helpful for exporting and backing up databases, you can learn more from the manual page with “man mysqldump” or by reading here on dev.mysql website.

How to Import All Databases into MySQL

Of course if you have a database dump, importing that into MySQL is important. Here’s the simplest way to import all databases from a database.sql file into MySQL via command line:
mysql database_name < database_dump.sql
And like exporting a database, when importing you can also specify a username if desired:
mysql -u root -p < database_dump.sql
You specify a different username or database if desired as well:
mysql -u user -p database_name < database_dump.sql

Importing a Specific Database into MySQL

You can also import a specific database in a large dump by name:
mysql --one-database database_name < all_databases.sql
As before, if you're having difficulties with importing databases into mysql you can turn to the manual page with 'man mysql' or to the official documentation here at the mysql developer site.
Know any interesting tricks for exporting databases and importing databases in MySQL? Let us know in the comments!

.

agenda 2023 (1) Algo que leer (260) Android (2) Angular (2) Apache (4) API (1) Arte y Cultura (11) Artes Marciales (10) Banner (1) Base de datos (29) Big Data (11) Budismo (4) cabala judia (2) Calculo Asistido por computadoras (2) Canaima (6) Caos (1) Ceo (1) ciencias (1) Cine (1) Cobol (1) Cobra Kai (1) Codigo Linux Documental (2) Computación (3) Computación forense (14) Configurando Samba (1) Consola (8) Criptomonedas (3) Darkweeb (3) Data Mining (1) Debian (1) DeepWeb (7) demografia (6) Deporte y Recreación (9) Deportes (10) Desktop (1) developers (1) Document (1) Ecología (6) Editor (2) Educacion y TIC (27) Electronica (2) Emprendimiento (7) Espiritualidad (2) estoicismo (3) Eventos (2) Excel (1) Express (1) Filosofía (23) Flisol 2008 (3) Flisol 2010 (1) Flisol 2015 (1) framework (1) Funny (1) Geografía (1) Gerencia y Liderazgo (72) Gestor de Volúmenes Lógicos (1) Git (5) GitHub (6) gnu (23) Go (1) gobiernos (1) golang (2) Google por dentro (1) GraphQL (1) gRPC (1) Hackers - Documental (8) Hacking (30) howto (188) html (1) IA (7) IntelliJIDEA (1) Internet (6) Introducción a los patrones (2) J SON (1) java (36) java eclipse (2) javaScript (8) JDK (1) jiujitsu (4) Json (1) kali (37) kernel (2) Kotlin (1) Laravel (2) Latin (1) LIbreOffice (1) Libros (4) Linux (34) Linux VirtualBox (1) Literatura (1) Manuales (42) Markdown (1) Marketing (1) Matando ladilla (9) Matematricas (1) Math (1) maven (1) metodos https (1) Modelos (1) MongoDB (17) Multimedia (1) mvc (2) Mysql (19) MySQL Workbench (1) Nagios (2) Naturismo (1) node (2) Node.js (3) NodeJS (6) NoSQL (1) Oracle (3) Oracle sql (3) Php (1) PL/SQL (1) Plsql (1) PNL (1) Poblacion (2) Poesia (1) Politica (2) Política (1) Postgresql (1) PowerShell (1) programacion (67) Psicologia (9) Python (4) Redes (31) Religion (2) REST (2) Rock/Metal Mp3 (1) RUP (1) Salud (5) sc:snap:android-studio (1) sc:snap:datagrip (1) sc:snap:gitkraken linux (1) Seguridad (14) Seguridad con Gnu Privacy (2) Seo (1) simulaEntrevistas (9) Sistemas Operativos (69) SOAP (1) Sociedad (2) Software Libre (169) Soporte Tecnico (12) Sphinx (1) spring (1) spring boot (8) SQL (3) SQL en postgreSQL (38) Taekwondo (11) Tecnología (27) Tor (9) Trialectica (3) TYPEACRIPT (1) Ubuntu (5) Vida activa (1) Videos (11) Videos Educativos (10) Vim (1) Viral (3) Visual Studio (1) wallpaper (2) Wifi (2) Windows (3) WWW (2) Xrandr (1)

Sabiduria Justicia Templanza Coraje.

Hay que contemplar las potenciales consecuencias de nuestros planes, para impedir que nos sorprendan. De esta manera, tendremos más control sobre las situaciones difíciles.


Powered by