Effacer les filtres
Effacer les filtres

Call command line MySQL with user and password

1 vue (au cours des 30 derniers jours)
Jos
Jos le 17 Juil 2014
Réponse apportée : Jos le 18 Juil 2014
Hi,
I'm trying to call MySQL from Matlab in the same way you can call it from the DOS command line, i.e. (without the quotation marks)
"mysql -utestuser -ptestpass < query.txt > output.txt"
This syntax works in a DOS command prompt, but when I use the same command with the system() function in Matlab, so
system('mysql -utestuser -ptestpass < query.txt > output.txt')
I get "error 1045 (28000): Access denied for user 'testuser'@'localhost' (using password: NO)".
It looks like the password isn't passed to the mysql command properly. I've tried a couple of different combinations of single and double quotation marks, but none seem to work. Do you know if it's possible to pass a MySQL command like this from Matlab and if so what the exact syntax should be?
I cannot get the ODBC driver installed on this machine, which is why I'm trying to do it in this way
Thanks!
Joe

Réponse acceptée

Jos
Jos le 18 Juil 2014
Found the solution myself, might be helpful for someone else, write the mysql command to a batch file (e.g. test.bat) and call the batch file using the system command, system('test.bat'). This works around the formatting issues

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by