2
votes

I just installed mysql 5.7.23 on my mac sierra 10.13.5.

I saved this to a notepad:

2018-09-02T05:39:56.919171Z 1 [Note] A temporary password is generated for root@localhost: =su8S7ge4d4X

If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

I tried to log in using the password mysql -u root -p =su8S7ge4d4X

Got error:

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

Tried to change password:

  1. Stop the mysqld server.

    • Mac OSX: System Preferences > MySQL > Stop MySQL Server
  2. Start the server in safe mode with privilege bypass

    • From Terminal: sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
  3. In a new terminal window:

    • sudo /usr/local/mysql/bin/mysql -u root
  4. This will open the mysql command line. From here enter:

    • UPDATE mysql.user SET authentication_string=PASSWORD('NewPassword') WHERE User='root';

    • FLUSH PRIVILEGES;

    • quit

  5. Stop the mysqld server again and restart it in normal mode.

    • Mac OSX (From Terminal): sudo /usr/local/mysql/support-files/mysql.server restart

It doesn't look like any rows are being affected:

mysql> UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE User='root';
Query OK, 0 rows affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 0  Warnings: 1

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

Still tired to login:

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

I have no idea what to do at this point.

1
Remove the space before your password, as described on dev.mysql.com/doc/refman/8.0/en/… - Progman

1 Answers

1
votes

Try mysql -u root -p then hit enter. If it prompts for a password, then you type your password.