I have a mysql server on a linux box (192.168.1.20) which has database named "retail". I want to create an automatic way to do a backup on windows server (192.168.1.30).
What is the best way to run the following code to do so :
mysqldump -h 192.168.1.20 -u root -p Retail > C:\Retail_Initiative\backup_20110315.sql
Any kind of help will be greatly appreciated.
How about creating a bat file with:
/START /WAIT mysqldump -uUSERNAME -pPASSWORD -h192.168.1.20 retail > path_to_dump_file
/START /WAIT mysql -uUSERNAME -pPASSWORD -h192.168.1.30 -e "DROP DATABASE retail; CREATE DATABASE retail;"
/START /WAIT mysql -uUSERNAME -pPASSWORD -h192.168.1.30 retail < path_to_dump_file
That should do it.
Related
i have issue to daily backup for mysql database.
export only all tables with data but not mysql function and stored procedure.
how to get full database backup?
I have use this cronjob.
mysqldump –opt -Q -h [myhost] -u myusername –p"*****" ebooklibrary > /fullpath.../_db_backups/openelibrary.sql
Add the "--routines" option, which is off by default in the query. This should give you the desired result. I hope this helps.
Read more here.
mysqldump --routines –opt -Q -h [myhost] -u myusername –p"*****" ebooklibrary > /fullpath.../_db_backups/openelibrary.sql
I have a 108MB SQL file, how can i import this file in server using PHP Script?
I try to do this, but no result
mysql -h 213.xyz.200.xx -u myUsername -p MyPassword MyDatabase < temporarytable.sql
Take the space out after the -p or don't put the password in at all and it will prompt you for it.
mysql -h 213.xyz.200.xx -u myUsername -pMyPassword MyDatabase < temporarytable.sql
I am trying to create a batch file in Windows to backup a MySQL Database, i have tried this:
C:\xampp\MySQL\bin\MySQLDump –u root –p database_name –result-file=”C:\Users\Administrator\Desktop\MySQLDump.sql”
but i get an error saying:
Got error: 1044: Access Denied for user ``#`localhost` to database `?u` when selecting the database
The solution to this problem/error was to use one of these mysqldump commands:
mysqldump --opt --lock-tables=false -u USER -p DBNAME > dump.sql
mysqldump --opt --single-transaction -u USER -p DBNAME > dump.sql
http://alvinalexander.com/mysql/mysql-error-1044-access-denied-for-user-using-lock-tables
Try this, it worked for me.
Don't forget to replace values inside {} as you need
C:\xampp\mysql\bin\mysqldump.exe -u{username} -p{passwrod} database > {/backuppath}.sql
Completed guide can be found at here:
https://www.tectut.com/2016/04/automatically-backup-mysql-databases-on-windows/
I want to have a database backup our database is hosted in amazon rds. My problem in everytime i run my PHP script it generates an sql file but it is empty.
Here is my code:
exec("/usr/bin/mysqldump -u *username* -p *password* | gzip > /var/www/html/db-backup/testdb.sql.gz");
I think that you need to specify which database you want to backup
exec("/usr/bin/mysqldump -u *username* -p*password* *dbname* | gzip > /var/www/html/db-backup/testdb.sql.gz");
and you have to specify password next to -p parameter without space (mysqldump -u youruser -pyourpassword -h yourhostname yourdatabase)
I have got alldatabase.sql file
How I can restore data with it?
My console comand is not working:
mysqldump -u root -p < alldatabase.sql
I must to create database first, but all database in my one file. What I must to do?
You use mysqldump to take a snapshot, but you restore using the mysql command
mysql -u root -p < alldatabase.sql