Score:0

Can't run mysql commands as root linux user

in flag
Dan

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?

(Environment details: fresh Ubuntu 20.04 install, mysql installed with apt)

Marc Vanhoomissen avatar
in flag
Does this answer your question? [while running mysql -u root got ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)](https://askubuntu.com/questions/1269936/while-running-mysql-u-root-got-error-1045-28000-access-denied-for-user-root)
Marc Vanhoomissen avatar
in flag
This is a common mistake. User 'root' for mysql is not user 'root' for Ubuntu. You have to define a specific password for mysql user 'root'. See eg this: https://askubuntu.com/questions/237362/mysql-access-denied-for-user-root-while-using-lamp/254654#254654
in flag
Dan
I'm not specifying a mysql user. I just want to run mysql commands as sudo/root. Lots of applications, i.e. running commands in an install script
cn flag
Provide the password you setup mysql's user "root" with. If not you don't have a root user in mysql. root mysql != root Ubuntu "Shouldn't the root user be able to run mysql without additional authentication?" UNLESS you set it up with a password.
jp flag
Dan
Installing MySQL on Ubuntu will require a password for the root user. Since a while ago, you can't have a passwordless root account by default in MySQL. During the package installation, you must have been asked to input a password.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.