Get the App
SLTechnology News&Howtos  ›  Database  › 

Import and export of mysql

Shulou Source: shulou.com Published: 2022-06-01 14:02:23 10月04日 Update

MySQL command line export database

1. Go to the bin folder under the MySQL directory: the directory to the bin folder in cd MySQL is like the command line I entered: cd C:\ Program Files\ MySQL\ MySQL Server 4.1\ bin

2. Export the database: mysqldump-u user name-p database name > exported file name such as the command line I entered: mysqldump-u root-p news > news.sql (after entering, you will be asked to enter the password for entering MySQL) (if you export a single table, enter the table name after the database name)

3. You will see that the file news.sql is automatically generated to the bin file under the command line to import the database.

1. Move the imported .sql file to the bin file, which is more convenient.

2, same as step 1 derived above

3. Enter MySQL:mysql-u user name-p as I typed the command line: mysql-u root-p (the same will let you enter the password of MySQL)

4. Create the database you want to build in MySQL-Front, which is empty. For example, create a new target database named news.

5, enter: mysql > use target database name such as the command line I entered: mysql > use news

6, import file: mysql > source imported file name; such as the command line I entered: mysql > source news.sql; MySQL backup and restore, are completed by using mysqldump, mysql and source commands.

Back up the database:

Enter cmd to export all databases: enter: mysqldump-u [database user name]-p-A > [path to save backup files]

Export data and data structure: enter: mysqldump-u [database user name]-p [database name to be backed up] > [save path of backup file]

Example: mysqldump-u root-p test > d:\ test.sql Note: this backup only backs up data and data structures, no backup stored procedures and triggers

Export data only but not data structure: enter: mysqldump-u [database user name]-p-t [database name to be backed up] > [save path of backup file]

Export the Events input in the database: mysqldump-u [database user name]-p-E [database user name] > [save path of backup file]

Export stored procedures and functions in the database mysqldump-u [database user name]-p-R [database user name] > [save path to backup file]

Import database mysql-u root-p

Tags: Data database file input backup user user name command path name data structure structure password file name folder directory target procedure storage example Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi macOS vpn OPPO Reno