How to Backup (Export) and Restore (Import) MySQL or MariaDB Database

Backing-up and Restoring databases in MySQL is a very straight forward process using the terminal.

To Backup a Database

mysqldump -u [username] --password=[passwd] [database] > [file].sql

This will create the file in the same directory. This is basically a text file and can be opened using any text editor.

To Restore a Database

mysql -u [user_name] --password=[your_password] [database] < [file_name].sql

This will restore all the data and tables to the existing Database that has been mentioned.

To Import a new Database

mysql -u [user_name] --password=[your_password] < [file_name].sql

Simply skipping the name of the existing database will create the new one based on the [file_name].sql file provided.

Note:

To can skip the –password=[your_password] in all of these commands with -p switch and it will ask for the password later. From a security point of view this would be better as password as plain text won’t be stored in the .mysql_history file.

HTML, CSS, JavaScript, AJAX, PHP & MySQL Best Practices

I have listed some resources which I found useful which come under the heading, Best Practices!

20+ HTML Forms Best Practices for Beginners
http://net.tutsplus.com/tutorials/html-css-techniques/20-html-forms-best-practices-for-beginners/

30 CSS Best Practices for Beginners
http://net.tutsplus.com/tutorials/html-css-techniques/30-css-best-practices-for-beginners/

24 JavaScript Best Practices for Beginners
http://net.tutsplus.com/tutorials/javascript-ajax/24-javascript-best-practices-for-beginners/

24 Best Practices for AJAX Implementations
http://net.tutsplus.com/tutorials/javascript-ajax/24-best-practices-for-ajax-implementations/

30+ PHP Best Practices for Beginners
http://net.tutsplus.com/tutorials/php/30-php-best-practices-for-beginners/

Top 20+ MySQL Best Practices
http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/

Install Apache, PHP and MySQL on Ubuntu

Installing these packages on Ubuntu is very simple. Just execute the following commands and you will be done with everything.

Install Apache

sudo apt-get install apache2

Install PHP

sudo apt-get install php5 libapache2-mod-php5

Install MySQL (with Apache & PHP support)

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Restart Apache

sudo /etc/init.d/apache2 restart

Install MySQL Query Browser

sudo apt-get install mysql-query-browser

Update for MySQL

MySQL has officially declared EOL (End of Life) for Query Browser. You can check it onhttp://dev.mysql.com/doc/query-browser/en/

MySQL Workbench is its replacement and its now available in Ubuntu 12.04 repositories:

sudo apt-get install mysql-workbench

All features are supported by Workbench.