I have a bash script that's supposed to talk to a MySQL database like this:
mysql --login-path=local -e "DROP SCHEMA mydatabase;"
When the script tries to connect to MySQL, it gives the error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
System info:
- ubuntu server 18.04
- mysql 5.7.28
MySQL Install Info:
Apt installed mysql, ran mysql_secure_installation
Set root password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypassword';
FLUSH PRIVILEGES;
Created ~/.my.cnf
file:
[local]
user=root
password=mypassword
I'm new to MySQL and imagine the solution is simple, but I'm having a hard time figuring it out. How can I make this work without changing the bash script?
Best Answer
I was able to make it work using the config editor.
From terminal: