Find programmers and grapic design experts at ScriptLance.com
<? DEW-CODE.COM  

Downloads

Assorted scripts  (1)
DewNewPHPLinks  (5)





Lost Password?
No account yet? Register

Dew-Code Newsfeed

More Dew-Code Stuff

Tech & Net Video
Many people seem to the think Dew-Code.com is ran by a group of people, or some big corporation. Well, it's flattering if you have that impression, but the truth is, its just one person. While I'd love nothing more than to continue giving away my scripts, my time and experience, I do have the same needs as everyone else. If you've found Dew-Code.com , or any of the scripts found there to be helpful, please consider making a contribution.

As of 6/9/08, A total of $75 USD has been contributed, or roughly $15 per year that I've been maintaining DewNewPHPLinks. While that is of course appreciated, unless more contributions are received, I will have no choice but to make future scripts, available for purchase only.

Regards,
Dewed
Dew-Code.com

Copying/Moving a MySQL database E-mail

Image
Open source to the rescue !
If you ever have to move a database from one server to another, perhaps you'll find these notes handy. I know I do.

Moving a MySQL database can be challenging.

If you have access to PHPMyAdmin, it can be done fairly easily, but I won't go into that here, since the process varies depending on what version of PHPMyAdmin you have access to. It's also a bit limited on the size and number of tables it can handle.

Personally, I prefer to copy databases using a command line tool called mysqldump.  

That would require you to have access to a BASH prompt on your server, via SSH, or maybe telnet. If you do use SSH... here is how to copy a database.
On the source server...

mysqldump -p -h localhost DBNAME table1_name table2_name table3_name | gzip > ./mydb.gz

After entering your mysql password, you'll have a compressed file of insert statements ready to be downloaded to the target server.

You can use SCP to copy your file directly to the target server
scp -l128 remoteusername@source_server.com:./mydb.gz

After entering the SSH password for remoteusername the gzip file will start downloading.

Afterwards, uncompress the file.

gzip -d ./mydb.gz

The resulting "mydb" file may need a little editing. I like to add a "USE DATABASENAME;" as the first line to simplify restores. It's also handy when I find the backup file a year later.. I can see which database it went to.
Once thats done, you can execute all the SQL statements in the mydb file like this ...
mysql -p <./mydb

After entering your MySQL password, you'll soon have an exact copy of the database from the source server.
 
< Prev

Newsflash

Sign up for PayPal and start accepting credit card payments instantly.
Copyright Dew-Code 2008