Search This Blog

Friday, March 16, 2012

How to restore MySQL database from sql dump file?

There are 2 ways to restore your MySQL database from sql dump file.

1st way to restore mysql database from sql dump file is using mysql web control panel – phpMyAdmin
- Log into phpMyAdmin.
- Select your preference database on the left database navigation drop down list.

- Click on Import tab on the top.
- Select your sql dumb file at File to import
- Then select your mysql database charset (ex: Latin1, utf-8)
- and click GO and it's done!

Do not use phpMyAdmin to import or restore your MySQL database if your MySQL database file is large. This is because, phpMyAdmin has limit on total upload size which depend on php setting. Besides, there is also maximum execution time which may cause browser to time out.

The solution to restore large mysql database from sql dump file is using unix/linux shell command.
To restore mysql database from a dump file, just type the command below:-

mysql -u #username# -p #database# < #dump_file#

Of course you need to replace #username# to your database username and #database# to your target database. and rename #dump_file# to your dump file file name (Ex: dump.sql) Once you enter the command, the linux/unix shell will prompt you for your database user password, just key in your database password and you are done.

Source: http://www.techiecorner.com/31/how-to-restore-mysql-database-from-sql-dump-file/

Enabling .htaccess file in Linux

Enabling .htaccess file

.htaccess file is a powerful file that can be used to control and customize a site server behavior without editing the core Apache module. By default, the .htaccess functionality is turned off and all instances of .htaccess files are completely ignored. The server will not even attempt to read .htaccess files in the filesystem.

To enable .htaccess file, open up the settings file that you have created earlier:

gksu gedit /etc/apache2/sites-available/default

Scroll down the file until you see the part "<Directory /home/user/public_html/>". Underneath that line of code, change AllowOverride None to AllowOverride All.

apache-allowoverride

Save and exit the file.

In case of local host you may found above section of code as follows:


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/

Also, if you need to use rewrite rules you need to enable them first. You do that with the following command.

sudo a2enmod rewrite
Prior to running that command you may get an error similar to the following.
[Tue Apr 14 14:23:34 2009] [alert] [client 127.0.0.1] /var/www/wiki/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

Finally, don't forget to restart Apache.

sudo /etc/init.d/apache2 restart