简体   繁体   中英

Access Denied for User 'root'@'localhost' (using password: YES) or (using password: NO)?

I have installed mysql in mac big sur using homebrew as

brew install mysql

But during the

GRANT ALL PRIVILEDGE

I mistakenly gave some other password to root and thus not able to start mysql again.

Tried all the steps/ suggestions for this question all over stack-overflow and blogs but did not get full steps anywhere (probably I might have missed it somewhere)

I tried to stop mysql and then start with --skip-grant-tables but it is still giving me same error for the second command.

Tried uninstalling and reinstalling but upto no progress so far

By going through multiple answers I found this steps which worked for me

Mac OS: Big Sur 11.6.8 MySQL: 8.0.30

Steps:

  1. Uninstall mysql. (In my case I am using homebrew)

brew uninstall mysql

  1. Reinstall mysql

brew install mysql

  1. Goto path and open the file in editor

/usr/local/etc/my.cnf

  1. Copy this in the file

[mysqld]

skip-grant-tables

(You might already have the "mysqld" section so just add the line below it)

  1. Goto terminal
  2. Stop mysql service if running

mysql.server stop

  1. Run the command

mysqld_safe --skip-grant-tables --skip-syslog --skip.networking

  1. Start mysql as you won't have to enter password again now

mysql -u root

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM