3

Following Problem:

I have a login to a MySql-Database in a batch-File, logging in with root and no password, but at the moment, i have to press enter when asking for a password, but I want this automatically, so just putting it in the batch-File that the enter-Key is automatically pressed. Something like echo; does not work because it's proceeded only after I manually pressed enter. Anybody has an idea for that?

The code I'm using is mysql -u root -p < ../../htdocs/leadCapt/leadcaptapp.sql (I'm actually importing a database) Thanks.

2 Answers2

0

I think this will help: Press Keyboard keys using a batch file. However, I would recomend bot to use a bat script for this. You should take a look at AutoIt. It's a really simple script language, can be compiled to exe files or run as script and allows you interact with GUI (hit enter key or even click "ok" button) objects easily.

Community
  • 1
  • 1
MichaelS
  • 5,941
  • 6
  • 31
  • 46
0

Although it's generally a bad idea to have a root account with no password, if you remove the -p parameter from your command line, MySQL will try and log in without a password.

No need to mess about with pressing enter keys and such.

Luke Peterson
  • 8,584
  • 8
  • 45
  • 46