Training

When: Every first Sunday of every month -get a ticket- from $15 (Click Here).

Friday, March 11, 2016

Linux and Microcontroller Tips: How to Import / Export OR Backup / Restore MySQL Database in Ubuntu Linux with mysqldump

How to  export / Backup a  Mysql database to a .sql file


# mysqldump -u USERNAME  -p DATABASENAME > FILENAME.sql



USERNAME is the MySQL admin user

DATABASENAME  is the name of the database that need to be exported /Backup

FILENAME.sql is the name of the file where your data will be exported



Now It will ask for password,Enter  MySQL admin password. 



You can dump all databases by doing:



# mysqldump -u root -p --all-databases > all_my_data.sql



Now We can See How to Import/Restore MySQL database:
Below is the simple command through which you can restore / import the already exported MySQL database file (.sql)



# mysql -u USERNAME -p DATABASENAME < FILENAME.sql



Linux and Microcontroller Tips: How to Import / Export OR Backup / Restore MySQL Database in Ubuntu Linux with mysqldump


UPDATE: for MySQL

1- dump the .sql file  (remember to do a pwd)
2- jump into mysql ($ mysql -u root -p)
3- once in, do  mysql> source /path/of/working/direcotry/filename.sql;
4- that's it baby

No comments: