Thursday 18 March 2010

mysqldump from remote host

First you need to set the appropriate privileges on the target SQL server.

In this instance I want to use mysqldump to backup a database using a nightly script.

For this example assume the following;

mysql server host: myserver.example.org
target database: mydb
Backup host: backup.example.org
Backup username: backup

On the mysql server log in as root with;

mysql -u root -p

Enter this on the mysql console;

GRANT SELECT,LOCK TABLES ON mydb.* TO backup@backup.example.org
flush privileges;

On the backup server run this command;

mysqldump --host=myserver -u backup mydb > test.sql

Assuming that works, you can put the final command into your backup shell script or simply place it in your crontab.

3 comments:

Bruce said...

Thank you :-)

Manoj Bardhan said...

Help me,
I need mysqldump in remote server .

when I am running in my own pc (localhost) its works find but when the script is running in server not working.

File is created but no data.


Help Me.
manojbardhan2009.blogspot.in

sgr said...

.hey..thanks..it worked really well for me.. :)