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
-
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!
-
@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
@mcosta How can I use dumpsql within c++ programming?
-
@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/dirYou 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]* | mysqlor an antoher alternative is:
shell>mysqldump --opt database > backup-file.sqlrestore:
mysql database < backup-file.sqlor
mysql -e "source /patch-to-backup/backup-file.sql" databaseIn 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 databaseIt is possible to dump several databases with one command:
mysqldump --databases database1 [database2 database3...] > my_databases.sqlIf 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