Access denied for user root - mysql on MAC OS

后端 未结 10 1675
面向向阳花
面向向阳花 2020-12-23 22:32

I know how do skip this problem on ubuntu, but how can i do it on MAC OS?

How can i set password for mysql on MAC?

1) Doesn\'t work

mysqladm         


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 23:16

    MACOS 10.14 MOJAVE || MYSQL 8.0.15

    This didn't work on my mac:

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

    BUT THIS ACTUALLY WORKED:

    sudo /usr/local/mysql-8.0.15-macos10.14-x86_64/support-files/mysql.server stop
    

    The installation folder might vary per user, BE AWARE!

    Or just Check > System preferences > MySQL > if the server is running, stop it.

    then,

    Start MySQL with this command:

    sudo /usr/local/mysql-8.0.15-macos10.14-x86_64/bin/mysqld_safe --skip-grant-tables
    

    Open a new terminal window/tab:

    sudo /usr/local/mysql-8.0.15-macos10.14-x86_64/bin/mysql -u root
    

    This should open "mysql" prompt. Execute the following command (*scroll right if you don't the full query):

    UPDATE mysql.user SET authentication_string='your-password-goes-here' WHERE user='root' and host='localhost';
    

    REMEMBER THAT

    mysql-8.0.15-macos10.14-x86_64

    (in my case) is the installation folder on your local machine, and it might or might not be different than mine because of OS versions, mysql versions, installation methods used, etc.

提交回复
热议问题