Blog Archive

Wednesday, April 28, 2010

Backup and Restore MySQL Database

How to Backup and restore MySQL database from sql dump file?

mysql, mysql database, sql database, sql, database server, server,  sql database server, mysql database server

Backup:

Playing with mysqldump

If you have either a shell or telnet access to your database server, you can backup the database using mysqldump. By default, the output of the command will dump the contents of the database in SQL statements to your console. This output can then be piped or redirected to any location you want. If you plan to backup your database, you can pipe the output to a sql file, which will contain the SQL statements to recreate and populate the database tables when you wish to restore your database. There are more adventurous ways to use the output of mysqldump.

A Simple Database Backup:

You can use mysqldump to create a simple backup of your database using the following syntax.

mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]

    • [username] - this is your database username
    • [password] - this is the password for your database
    • [databasename] - the name of your database
    • [backupfile.sql] - the file to which the backup should be written.
       

The resultant dump file will contain all the SQL statements needed to create the table and populate the table in a new database server. To backup your database 'Customers' with the username 'sadmin' and password 'pass21' to a file custback.sql, you would issue the command:

mysqldump -u sadmin -p pass21 Customers > custback.sql

You can also ask mysqldump to add a drop table command before every create command by using the option --add-drop-table. This option is useful if you would like to create a backup file which can rewrite an existing database without having to delete the older database manually first.

mysqldump --add-drop-table -u sadmin -p pass21 Customers > custback.sql


Playing with mysqldump

If you have either a shell or telnet access to your database server, you can backup the database using mysqldump. By default, the output of the command will dump the contents of the database in SQL statements to your console. This output can then be piped or redirected to any location you want. If you plan to backup your database, you can pipe the output to a sql file, which will contain the SQL statements to recreate and populate the database tables when you wish to restore your database. There are more adventurous ways to use the output of mysqldump.

A Simple Database Backup:

You can use mysqldump to create a simple backup of your database using the following syntax.

mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]

    • [username] - this is your database username
    • [password] - this is the password for your database
    • [databasename] - the name of your database
    • [backupfile.sql] - the file to which the backup should be written.
       

The resultant dump file will contain all the SQL statements needed to create the table and populate the table in a new database server. To backup your database 'Customers' with the username 'sadmin' and password 'pass21' to a file custback.sql, you would issue the command:

mysqldump -u sadmin -p pass21 Customers > custback.sql

You can also ask mysqldump to add a drop table command before every create command by using the option --add-drop-table. This option is useful if you would like to create a backup file which can rewrite an existing database without having to delete the older database manually first.

mysqldump --add-drop-table -u sadmin -p pass21 Customers > custback.sql

Restore
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

Sunday, April 25, 2010

Save youtube videos from firefox cache

How could we save a copy of youtube videos or any other video from the Firefox cache folder :
  1. Wait for the flash video loading completely, i.e. able to play  to the end
     
  2. Open a new tab / window of Firefox and enter about:cache as an URL
     
  3. Take note of the Firefox cache folder path specified in Cache Directory: and browse to this folder with Windows Explorer

    If the Storage In Use greater than or approaching Maximum Storage Size, the video might not be cached completely or you'll have to increase Maximum Storage Size and reload the video again.

    To set Firefox cache folder maximum storage size, click Tools | Option… | Network | Cache
  4. Sort the cached files by file size and try to open the biggest file with Storm Codec-MPC or FlV Player/ VLC media Player. (The biggest file is likely to be the cached YouTube video)
  If you want to know what those files in the Firefox cache folder exactly are, here we go:
  1. While in the about:cache page, click the List Cache Entries link of the Disk cache device section
     
  2. Press CTRL + F to search for Key: (URL) with the get_video keyword and also with the biggest Data Size: (YouTube doesn't cache the flash video in FLV extension. For other flash video hosting site, you may save time by trying to search for .FLV extension).
     
  3. Right-click the URL and select the Open Link In New Tab and refer to the File on Disk:
There are many Firefox plugins available to save flash video. However, if you're not regularly download flash video, then it's worth to know how to do it manually. Running too many plugins might slow down the Firefox or overall PC performance too :-)

Tuesday, April 6, 2010

Changing Default Gateway using many lan

If many LAN interference are used the default gateway can be changed by
command (in XP ,server 2003)
route change 0.0.0.0 mask 0.0.0.0  <IP of gateway preferred>

Followers