As linux root user:
root@local:~# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
I'm confused. Shouldn't the root user be able to run mysql
without additional authentication? How do I fix this?
CodePudding user response:
Your root account in MySql has a password. Try this
mysql -p
and enter the password you, or somebody set.
If that doesn't work try
mysql -h localhost -u root -p
It that doesn't work you'll need to reset your MySql root password. That's the topic of several tutorials on the 'toobz
CodePudding user response:
If the MySQL root user has a password, using the default authentication plugin, then you must provide a password to connect, full stop. You can configure an account with no password, but that's a habit you should avoid.
You can provide a password by any of the following means:
- Entering it interactively with the
-p
option - Entering it in plaintext in the commandline like
-p<mypassword>
- Storing it in plaintext in your
~/.my.cnf
file in the[client]
section (see https://dev.mysql.com/doc/refman/8.0/en/option-files.html) - Storing it in an obfuscated form in your
~/.mylogin.cnf
file (see https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html).
There's also a way to provide a password through environment variables, but that's discouraged now because it's really not secure.