MySQL mysqldump -u user -pyour-password-without-space-between-letter-p-and-your-password -default-character-set=utf8 -host $HOST database-name -r dump.sql Then, you MUST use -r option to write the file. Such as :ĮRROR 1064 (42000): You have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax to use near. As you can see, the process of exporting and importing a MySQL or MariaDB database is very simple.The problem with all these solutions (using the > redirector character) is that you write your dump from stdout which may break the encoding of some characters of your database. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |