I want to execute query in side the db.sql file using MySQL 5.1 in windows environment. Can any one help me to this. I want to do this by runing a bat file.
it gives a error'access denied with password no' how can i give the username and password
ganuke
2010-05-28 07:44:00
@ganuke: http://dev.mysql.com/doc/refman/5.1/en/mysql.html
Ignacio Vazquez-Abrams
2010-05-28 07:47:49
@ganuke by typing `mysql --help` you can get help on using mysql console
Col. Shrapnel
2010-05-28 07:49:05
+1
A:
Col Shrapnel's answer is the way to do it. The batch file would look like this:
mysql < %1
...which really just shows that it'd just be easier to use that directly instead of a .bat.
runsql myfile.sql // (assuming you name your batch file "runsql.bat")
// vs
mysql < myfile.sql
Reading your comment on the other answer, it seems like you might actually get some use out of the batch file as long as you don't mind storing your password in plain text on your computer.
Make the batch file like this:
mysql -u myusername -pmypassword < %1
Note that there is no space between -p
and mypassword
. If you use that above, every script would have to specify which database to use, which might be a hassle. The other way you could do it is like this:
mysql -u myusername -pmypassword -D %1 < %2
And the usage would be:
mysql database_name input.sql
nickf
2010-05-28 07:38:21
mysql -u root -proot test < db.sqlthis worked for me. but the problem is i have to run the bat file inside the mysql bin folder. I want to run it from the desktop. How can I specify the path
ganuke
2010-05-28 08:19:20
a) add the mysql bin folder to the system path. -OR- b) type the full path into the batch file (`c:\mysql\bin\mysql -u ....`)
nickf
2010-05-28 08:22:55