copy table contents accros different servers in Qt
-
In developing a Qt application I need to copy contents of a mysql table from serverA(PC-A) to serverB(PC-B). What is best way to do this? (I can't use dumpmysql and don't want to use QProcess.exe)
THANKS
-
@alizadeh91 said:
In developing a Qt application I need to copy contents of a mysql table from serverA(PC-A) to serverB(PC-B). What is best way to do this? (I can't use dumpmysql and don't want to use QProcess.exe)
THANKS
Hi,
obviously the "dumpsql" solution is the best way but if you cannot use it (I'm curious about why..) the only solution I can suggest is;- Create two QSqlDatabase connections
- Load all data from the serverA
- Insert all data into the serverB
Happy Programming
-
This post is deleted! -
@mcosta How can I use dumpsql within c++ programming?
-
Do a full backup of your databases:
shell> mysqldump --tab=/path/to/some/dir --opt --full
or
shell> mysqlhotcopy database /path/to/some/dir
You can also simply copy all table files (
*.frm',
.MYD', and `.MYI' files) as long as the server isn't updating anything.restore with:
shell> mysqlbinlog hostname-bin.[0-9]* | mysql
or an antoher alternative is:
shell>mysqldump --opt database > backup-file.sql
restore:
mysql database < backup-file.sql
or
mysql -e "source /patch-to-backup/backup-file.sql" database
In addition, you can still do the following:
However, it's also very useful to populate another MySQL server with information from a database:
mysqldump --opt database | mysql --host=remote-host -C database
It is possible to dump several databases with one command:
mysqldump --databases database1 [database2 database3...] > my_databases.sql
If all the databases are wanted, one can use:
mysqldump --all-databases > all_databases.sql
--> solution in c++:
C++: ShellExecute(0, "open", "c:\\mysql\\bin\\mysqldump.exe", "--opt database > backup-file.sql", 0, SW_SHOWNORMAL); restore: C++: ShellExecute(0, "open", "c:\\mysql\\bin\\mysql.exe", database < backup-file.sql", 0, SW_SHOWNORMAL);
hope this helps
-
Instead of ShellExecute, you can also use QProcess in Qt programs
Why you don't want use QProcess???