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!