mysqldatabaseauthenticationpasswordspassword-prompt

mysql is prompting for password even though my password is empty


I installed mysql on ubuntu server and did not specify password. When I do

mysql -u root -p 

it prompts for password and without providing any input I just hit enter and it works.

Now I need to perform some operation on the database using cron job. My cron job does not work because mysql prompts for a password. I tried doing

mysql -u root -p'' my_database

but that did not work either.

Any suggestion?


Solution

  • Try not asking mysql to prompt for the password, 'mysql -u myuser'. I would suggest you create an account with only the required privileges to do this. Also limit its access to localhost. Put a password on root.