Access denied for user root - mysql on MAC OS

后端 未结 10 1714
面向向阳花
面向向阳花 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:02

    I had a very hard time in fixing this issue on MAC Sierra, 10.12.6, MySql version 5.7.17

    Following steps worked for me:

    Open a Terminal window, use the command below to stop mysql if it's already running.

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

    Start MySQL with this command:

    sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

    Open a new terminal window/tab:

    sudo /usr/local/mysql/bin/mysql -u root

    This will open "mysql" prompt. Execute following command in mysql prompt one by one:

    use mysql;
    
    UPDATE user SET authentication_string = PASSWORD('my_new_password'), password_expired = 'N' WHERE User = 'root';
    
    FLUSH PRIVILEGES;
    
    EXIT
    

    Now Stop MySql server first then start it using below commands

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

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

    Hope this solves your issue.

提交回复
热议问题