Schedule an export? Using command line?

User, date Message
Written by bbb1981
5 years ago
Category: Import/Export
2 posts since Tue, 11 Dec 07
Would it be possible to use HeidiSQL to run exports/transfers automatically? This is my situation: I have a MySQL server on my network, and a remote MySQL server that I need to transfer data from. I need to be on a VPN connection to access the remote server. If I set up a dedicated machine that is always connected to the VPN, and have two instances of HeidiSQL open, is there any way I can schedule it to automatically export from the remote to the local server? Using command line?

Thanks for any suggestions.
Written by ansgar
5 years ago
3973 posts since Fri, 07 Apr 06
The commandline doesn't allow to trigger the export options yet, only connecting to a host is implemented, just like you can see in this revision and this posting.
Written by bbb1981
5 years ago
2 posts since Tue, 11 Dec 07
Yea actually those posts are what inspired me to ask this question!smile

Oh well, maybe in the future there will be a "scheduler" function inside the program itself.
Written by Tibi
5 years ago
5 posts since Tue, 18 Mar 08
Wenn ich richtig verstanden habe, kann ich also mit HeidiSQL automatisch per cmd / command Befehl mich mit einem Server verbinden.

Mein Befehl in der Batch-Datei lautet:
heidisql.exe -u USERNMAE -h HOSTENAME -p PASSWORD -db DBNAME

Verbinden ist kein Problem, aber wie kann ich nun eine SQL-Datei "Import.sql" ebenfalls automatisch ausführen lassen und nach erfolgreichem Upload HeidiSQL beenden?

Ich muss nämlich zeitweise am WebServer größere Datenmengen verändern bzw. Daten hochladen.

Würde mich über einen Tip freuen happy

Manuell verbinden mit der DB funktioniert einwandfrei und Daten können auch hochgeladen werden, nur noch nicht automatisch :(
Written by ansgar
5 years ago
3973 posts since Fri, 07 Apr 06
The export options cannot be invoked by command line. As HeidiSQL is a GUI application, it won't ever support too much command line handling.

I recommend using mysqldump for automated dumps.
Written by Tibi
5 years ago
5 posts since Tue, 18 Mar 08
Ich möchte aber kein Export, sondern ein Import in die DB durchführen.

Mit mysqldump kann ich zwar die Tabellen leeren, Index erstellen etc., aber leider keine 30-40 MB große TXT Dateien einlesen lassen.

Also ist auch kein IMPORT per commandline möglich?

So wie ich oben beschrieben habe, kann ich mich wunderbar verbinden, nur der SQL-Befehl bzw. die SQL-Datei müsste irgendwie noch ausgeführt werden.
Written by ansgar
5 years ago
3973 posts since Fri, 07 Apr 06
Ah sorry, so import is meant, not export. But it's the same thing: not implemented for the commandline options.

mysql(.exe) is capable of doing this on the commandline.
Written by Tibi
5 years ago
5 posts since Tue, 18 Mar 08
Schade, denn wenn ich eine TXT Datei Uploaden möchte auf den Server mit mysql.exe erhalte immer eine Fehlermeldung "access denied for user xxx"

Der WebServer ist bei Strato und die einzigste Möglichkeit, die Datenbank mit 30MB einwandfrei einzuspielen, ist bisher nur mit HeidiSQL möglich, aber eben nur manuell.

Daher wäre es schön gewesen, wenn ich nur noch hinter dem Befehl:

heidisql.exe -u USERNMAE -h HOSTENAME -p PASSWORD -db DBNAME

eine Anweiung geben könnte, dass eine bestimmte SQL Datei ausgeführt wird.
Written by ansgar
5 years ago
3973 posts since Fri, 07 Apr 06
As you initially wrote there is an "Import.sql" which you want to execute against your database from the commandline. This is exactly what mysql.exe is for. If you get an "Access denied" there you have some problem with the credentials, either a typo or empty password or so. Should be solvable easily.

However, in your last posting you're talking about a TXT file, which might also be a SQL dump, but probably might also be CSV file with delimited data in it. There is surely a difference beween the import processes of these two file types - SQL dumps can be imported via mysql.exe, CSV files also but with a different logic, using the LOAD DATA command. So, are we talking about a SQL file or delimited data?
Written by Tibi
5 years ago
5 posts since Tue, 18 Mar 08
Wir möchten bzw. müssen jede Nacht diverse Daten aktualisieren, wenn möglich automatisch.

Auf dem WebServer haben wir eine DB, in der gesucht werden kann.

Wir erhalten die Daten als CSV oder TXT Datei und hat eine Größe von ca. 20-30 MB.

Wenn ich HeidiSQL starte funktioniert d. Befehl einwandfrei und die 30MB an Daten werden sauber eingelesen:

LOAD DATA LOCAL INFILE 'C:\Temp\Test.csv' REPLACE INTO TABLE `testdb`.`tabelle` FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' (`id`,`ProzessID`,`Vorname`,`Nachname`,`PLZ`,`Ort`,`Telefon`);

Da ich aber das ganze automatisieren möchte und ich per mysql.exe eine Fehlermeldung erhalte (Berechtigungsproblem bei Strato und die können mir nicht helfen bzw. können die Berechtigungen nicht ändern), habe ich in eine Batch-Datei folgendes eingetragen:

heidisql.exe -u USERNMAE -h HOSTENAME -p PASSWORD -db DBNAME LOAD DATA LOCAL INFILE 'C:\Temp\Test.csv' REPLACE INTO TABLE `testdb`.`tabelle` FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' (`id`,`ProzessID`,`Vorname`,`Nachname`,`PLZ`,`Ort`,`Telefon`);

Leider klappt se mit der Batch Datei nicht ...mit d. Befehl wird nur HeidiSQL gestartet, mehr nicht.

Und mit folgendem Befehl (Batch-Datei) erhalte ich auch eine Fehlermeldung:
mysql.exe -h HOST -u dboxxxxxx -pPASSWORT dbxxxxxx < Test.sql

In der Test.sql steht nur:
LOAD DATA LOCAL INFILE 'C:\Temp\Test.csv' REPLACE INTO TABLE `testdb`.`tabelle` FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' (`id`,`ProzessID`,`Vorname`,`Nachname`,`PLZ`,`Ort`,`Telefon`);


Hoffe, dass ich noch ein Tip erhalte, wie ich d. ganze automatisieren kann.

Gruss 8)
Written by ansgar
5 years ago
3973 posts since Fri, 07 Apr 06
Please stick to english, so everyone can read your postings.

HeidiSQL's commandline interface does not support executing SQL scripts, only establishing a connection, as posted above. The only solution to a scheduled import is mysql.exe . If you get an error please post that message you got. If it's still the same you wrote above "Access denied..." you definitely have an issue in your password or username. I'm very sure you'll fix that problem with one of the various postings here.
Written by rosenfield
5 years ago
127 posts since Wed, 24 Jan 07
Meh, I for one would love to see command line options to invoke the export dialog, poke a few options in, and start the export :-P.

There's currently an option to log everything from the SQL / log window to a file, so error tracing is even covered, already.

(Error *handling* is not, but then it rarely is when it comes to scripting.)
 

Please login to leave a reply, or register at first.