Root user is denied access to MySQL
P粉208469050
P粉208469050 2023-11-09 11:00:45
0
1
624

I recently installed MySQL on x86_64*Ver 8.0.28-0ubuntu0.20.04.3 for Linux ((Ubuntu))*

After installation, when I try to access my shell it says

Error 1045 (28000): Access denied for user "root"@"localhost" (using Password: No)

With or without sudo, I know this has answers on stack and other forums but none of them seem to have helped me, I've tried reinstalling the MySQL server but that didn't help either, I've tried skipping the grant option , and then changed the root password but it also failed. I need help, thank you

P粉208469050
P粉208469050

reply all (1)
P粉752812853

You can reset your password with a single downtime. For version 8, just follow the steps below.

  1. Stop Mysql service $ systemctl stop mysql
  2. Now run the Mysql service in skip authorization table mode. $ mysqld_safe --skip-grant-tables &
  3. Log in to the service now $ mysql -uroot
  4. Execute refresh permission query
  5. Execute change query $ alter user 'root'@'localhost'identified by 'password';
  6. Stop the mysql service now $ systemctl stop mysql
  7. Now restart the mysql service $ systemctl restart mysql
  8. Now try to log in with the updated password
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!