Access denied for user root - mysql on MAC OS

后端 未结 10 1674
面向向阳花
面向向阳花 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 23:22

    You can do the following on iMac or Mac (High Sierra)

    Open a Terminal window, and stop the mysql if it's already running. You can also check this System Preferences > MySQL > see if it is running.

    Start MySQL with this command for skipping the main table

    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 should open "mysql" prompt. Execute the below command:

    A ) MySQL 5.6 and below

    UPDATE mysql.user SET password=PASSWORD('NewPassord') WHERE user='root';
    

    -- or --

    B) MySQL 5.7+

    UPDATE mysql.user SET authentication_string=PASSWORD('NewPassord') WHERE user='root';
    

    Restart MySQL, either through System Preferences > MySql or using a command.

提交回复
热议问题