MacOSX homebrew mysql root password

前端 未结 21 1636
自闭症患者
自闭症患者 2020-12-04 05:43

For some reason MySQL stopped giving access for root. Uninstalled and reinstalled with Homebrew. Fresh install, fresh tables but when I enter

mysql -u root -         


        
21条回答
  •  清歌不尽
    2020-12-04 06:15

    Use init file to start mysql to change the root password.

    brew services stop mysql
    pkill mysqld
    echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'newRootPass';" > /tmp/mysql-init
    $(brew --prefix mysql)/bin/mysqld --init-file=/tmp/mysql-init
    

    Your root password is now changed. Make sure to shutdown server properly to save password change. In new terminal window execute

    mysqladmin -u root -p shutdown
    

    and enter your new pass.

    Start your service and remove the init file

    brew services start mysql
    rm /tmp/mysql-init
    

    Tested on mysql version 8.0.19

提交回复
热议问题