how to reset my mysql password in mac os 10.13.3

后端 未结 2 1570
再見小時候
再見小時候 2020-12-20 05:48

I have a problem with MySQL. I forgot the password I used when I installed it so, I can not access to the server now. I tried deleting the MySQL and install it again but it

相关标签:
2条回答
  • 2020-12-20 06:17

    Try this command. I believe you should have mysql running. If that doesn't work try with mysql stopped.

    sudo mysql_secure_installation
    

    Hopefully should get you to prompt a password change.

    Also, for the socket error, you can try following this link. Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    0 讨论(0)
  • 2020-12-20 06:34

    You can try reseting the root password by running MySQL in Safe Mode.

    Here are the steps:

    1. Stop MySQL:

      sudo /usr/local/mysql/support-files/mysql.server stop

    2. Start it in safe mode:

      sudo mysqld_safe --skip-grant-tables

    This will be an ongoing command until the process is finished so open another shell/terminal window, and..

    1. Log in without a password as root:

      mysql -u root

    2. Update root (and any other user's) password)

      FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; \q

    3. Restart MySQL in normal mode

      sudo /usr/local/mysql/support-files/mysql.server start

    Reference: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/

    Note: this is pretty standard reset procedure, but just documented better in the above guide compared to mysql reference docs.

    0 讨论(0)
提交回复
热议问题