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
Call command line MySQL with user and password
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!