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?
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:
-p
option-p<mypassword>
~/.my.cnf
file in the [client]
section (see https://dev.mysql.com/doc/refman/8.0/en/option-files.html )~/.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.
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
I had same issue. This is what I do.
root@local:~# sudo mysql
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
mysql > FLUSH PRIVILEGES;
root@local:~# mysql
My problem solved.
ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;
Thanks to everyone who didn't understand the question or was too arrogant to believe there was a solution they weren't aware of and downvoted the question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.