In addition to script files, you can import data from a CSV, TSV, or any other text files that contain delimiter-separated values.įor more information about adding the SQL files that are stored on your machine to your project in DataGrip, refer to Attach a directory with SQL files. As you can see, the process of exporting and importing a MySQL or MariaDB database is very simple.To import data from a script file, run the file as it is described in the Run files page. If there is any type of error during the import process, it will be displayed on the screen. dump_filename.sql is the name of the file containing all the SQL commands that will be imported.new_database is the name of the database where the import will take place.username is the name of the user that has access to the database.mysql -u username -p new_database < dump_filename.sql When you are back to the normal command line, it will be time to launch a command to import the database. Once it has been created, you need to exit that Shell for doing so, use CTRL+D. If everything works correctly, you will see something similar to this: Query OK, 1 row affected (0.00 sec) Then, you will be able to create the database. This will open the Shell of MySQL or MariaDB. For doing so, if you do not have a database manager, you need to connect to the database server as a “root” user. To import a MySQL or MariaDB dump, the first thing to do is to create the database where the import will take place. After the import, only the selected tables will be overwritten. In this case, it is important to be especially careful with the relationships between the different registers. Mysqldump -u username -p database_name table_name_1 table_name_2 table_name_3 > dump_filename.sql For doing so, you must indicate in the command the selection you wish to do. It is also possible to export one or several tables instead of the whole database. Host: localhost Database: database_name This command should return something like this: - MySQL dump 10.13 Distrib 8.0.28, for Linux (x86_64) For doing so, you can use the following command: head -n 5 dump_filename.sql So, to verify the SQL copy has been done correctly, you can inspect the generated file in order to make sure it is a SQL copy. That command will not generate any visual output. dump_filename.sql is the file that will be generated with all the database information.database_name must be replaced by the name of the database you want to export.username refers to the database user name. ![]() To start exporting the database, execute the following command into the command line: mysqldump -u username -p database_name > dump_filename.sql Once the backup is created, the file generated can be easily moved. The name of the database you wish to export/import, and the username and password to access it.įor exporting the database, you can use the mysqldump command on the console.Access to the server where MySQL or MariaDB is installed and configured.To begin with, it is interesting to know the necessary requirements to import and export MySQL or MariaDB databases: 3 Importing a MySQL or MariaDB database Previous requirements to export and import databases
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |