4

I've searched for hours, there are many posts or tutorials but I couldn't run my batch script.

on dos prompt this code works fine:

-u root -h localhost -p******** siir_07 dumper.sql

but this gives error with batch:

"c:\program files\mysql\mysql server 5.5\bin\mysql.exe" "-u root -h localhost -p******** siir_07 dumper.sql"

the error is:

ERROR 1045 (28000): Access denied for user ' root -h localhost -p** siir_07 dumper.s'@'localhost' (using password: NO)

5 Answers 5

5

Z:\test.bat :

Z:\webserver\mysql\bin\mysql.exe -u test -p test < test.sql

When I run it from command line, everything is OK. So, try to remove quotes and redirect input using <.

Sign up to request clarification or add additional context in comments.

Comments

4

You can also use source to execute sql script for example

 mysql -u%DBUSERNAME% -p%USERPASSWD% -D%DBNAME% -e "source something.sql;"

Comments

1

you should redirect input from file using < and remove extra spaces:

mysql -uroot -p*** < dumper.sql

I would also suggest putting the username password, and most probabry charset parameters in a separate INI file and use it as follows:

 mysql --defaults-extra-file=myconf.ini < dumper.sql

1 Comment

thanks for the reply. i fixed it by removing last two quotes.
1

This solution worked for me:

mysql -u my_username -D my_database -p < test.sql

After this I got a prompt to enter my password, I did and everything worked.

Comments

0

it thinks this is your username

' root -h localhost -p** siir_07 dumper.s'

try changing the quotes around in your batch script

1 Comment

thanks for your reply. it just outputs mysql help text. i ve seen this before while i was doing trial and error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.