12-26-2020, 09:53 AM
@Rehan
Taking into account the above remarks, the command should be something like:
That's the way to do it!..
(08-22-2019, 08:47 AM)Rehan Wrote: Database Export via TerminalIt's always wise to use the host and port flags to explicitly set the server we're communicating with; the above command assumes a lot of things that aren't always correct. In addition to that, it's always a good idea to also explicitly mention the default-character-set to be used in that backup process (to avoid ending up with garbage text in the database. Bellow I used UTF-8, but you should use the one that you're database is using.
Code: (Select All)mysqldump -u [username] -p [database name] > [database name].sql
Taking into account the above remarks, the command should be something like:
Code: (Select All)
mysqldump --opt -u [username] -p --host=DB_SERVER_IP --port=DB_SERVER_PORT --default-character-set=utf8 --databases DB1_NAME DB2_NAME etc.. > ~/random_path/db_dump.sql
(08-22-2019, 08:47 AM)Rehan Wrote: (...........)That's WRONG!.. To restore A MySQL data_dump we use the 'mysql' commandline utility NOT mysqldump, like so:
(...)Code: (Select All)CREATE DATABASE newdb;
Use the following command to restore the database
Code: (Select All)mysqldump -u [username] -p [database name] < [database name].sql
Database restore is completed now (..................)
Code: (Select All)
mysql -u [username] -p --host DB_SERVER_IP --port DB_SERVER_PORT --default-character-set=utf8 --one-database DB1_NAME < ~/random_path/db_dump.sql
mysql -u [username] -p --host DB_SERVER_IP --port DB_SERVER_PORT --default-character-set=utf8 --one-database DB2_NAME < ~/random_path/db_dump.sql
etc......................
That's the way to do it!..