TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    MySQL

    MySQL mysqldump Export

    Overview

    In this tutorial, we will learn about MySQL mysqldump Export utility. The mysqldump utility dumps structure and contents of MySQL databases and tables.

    We can use this utility in different ways:

    • To dump full structure
    • To dump only data
    • To dump only table structure
    • To dump in a standard format

     

    mysqldump Utility

    The mysqldump utility only dumps the SQL statements. In order to use the dumped statements, we need to connect to a target MySQL server using with a client, and execute the dumped SQL statements.

    We can use mysqldump from the command shell. To view the options open command shell/prompt and issue the mysqldump command.

    >mysqldump
    Usage: mysqldump [OPTIONS] database [tables]
    OR mysqldump [OPTIONS] –databases [OPTIONS] DB1 [DB2 DB3…]
    OR mysqldump [OPTIONS] –all-databases [OPTIONS]
    For more options, use mysqldump –help

    Examples

    To dump a database to a text (.txt) file or (.sql) file using the mysqldump utility, use the redirect operator
    to indicate the filename and the location.

    In this example,we will export all the database tables and the data for a database. To dump the full world database to ‘world.sql’ file, we can issue the following command:

    > mysqldump world -u root -p > world.sql

     

    The -p option tells MySQL to prompt for a password. The –u option sets the database username. For example, root user.

    We can also dump a database to a text file using the mysqldump utility. To dump the world
    database to ‘world.txt’ file:

    > mysqldump world -u root -p > world.txt

    The data created in the dump file assumes that no table exists on the destination database server.
    The –add-drop-table option adds code to drop a table if it exists in the new target database
    when the file is imported.

    DROP TABLE IF EXISTS `city`;

    For example, a statement like above before creating the city table.

    MySQLDump Export Utility

    We can use the MySQL Workbench tool to open the dump file when dumped in .sql file. On Windows, we can right click on the world.sql file and choose open with MySQL Workbench utility.

     

    MySQL Workbench MySQL Dump File

    To dump some tables in the database, we can specify the tables as arguments after the database:

    > mysqldump world Country City

    This command will dump only the tables specified in the command.

    If we do not specify any table names following the database name or if we use the –databases
    or –all-databases option, the entire databases are dumped.

    Dump multiple databases

    To dump multiple databases, we can use the following commands:

    > mysqldump—all-databases

    > mysqldump—databases world sakila

    —

    MySQL Tutorials

    MySQL Tutorials on this website:

    https://www.testingdocs.com/mysql-tutorials-for-beginners/

    For more information on MySQL Database:

    https://www.mysql.com/

    Related Posts

    Stellar Converter for Database Tool

    MySQL /

    Stellar Converter for Database

    Stellar MySQL Log Analyzer

    MySQL /

    Stellar Log Analyzer for MySQL

    Stellar Repair for MySQL

    MySQL /

    Stellar Repair for MySQL

    MySQL /

    How to secure your SQL Database: Tips and Tricks

    Stellar Converter for Database

    MySQL /

    Database Converter Tools

    ‹ MySQL Export using INTO OUTFILE› Import Data Using MySQLImport Utility

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com