funguy
funguy

Reputation: 2160

How to setup mysql via bash without entering the password?

I am setting password like this:

  echo mysql-server mysql-server/root_password password "root" | debconf-set-selections
  echo mysql-server mysql-server/root_password_again password "root" | debconf-set-selections

When I want to do something like this:

 mysql -u root -p -e 'DELETE FROM mysql.user WHERE User="";'

Please note that the query itself is not the problem right now. I want to be able to run the query through bash without entering password, but as it is right now it still asks for password.

Also tried: mysql -u root -p root -e 'DELETE FROM mysql.user WHERE User="";'

Still, no luck. Also tried to set no password:

 echo mysql-server mysql-server/root_password password "" | debconf-set-selections
  echo mysql-server mysql-server/root_password_again password "" | debconf-set-selections

but it seems like it still prompts for password.

Upvotes: 0

Views: 63

Answers (1)

Cyrus
Cyrus

Reputation: 88654

Remove whitespace between -p and your password.

Upvotes: 1

Related Questions