필터 지우기
필터 지우기

Call command line MySQL with user and password

조회 수: 1 (최근 30일)
Jos
Jos 2014년 7월 17일
답변: Jos 2014년 7월 18일
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

채택된 답변

Jos
Jos 2014년 7월 18일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by