Score:0

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) after mysql -u root -p

gd flag

I am on Ubuntu 22.04 and MySQL version 8.0.30. I start mysql using the command:

systemctl start mysql.service

When I run systemctl status mysql.service I get this output:

mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-11-27 10:32:12 CET; 10min ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 41445 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 41484 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 6969)
     Memory: 395.6M
        CPU: 5.184s
     CGroup: /system.slice/mysql.service
             └─41484 /usr/sbin/mysqld

Then I do:

mysql -u root -p

It should now ask me for my password but it doesn't. Instead I get:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Any help would be appreciated.

in flag
If you need to sign in as the `root` account on MySQL, you must use `sudo mysql`. There is no requirement to state the user or password, as a system admin already has full access to the server. This change was made to MySQL 7 years ago
johannes avatar
gd flag
I believe that is the right answer. Thank you @matigo
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.