MacOSX homebrew mysql root password

前端 未结 21 1614
自闭症患者
自闭症患者 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:26

    I had this problem on a fresh install on Mac. I installed MariaDB with:

    brew install mariadb 
    

    Then started the service:

    brew services start mariadb
    

    I was unable to run 'mysql_secure_installation' as it prompted for the root password. Then I noticed in the install output:

    mysql_install_db --verbose --user=jonny --basedir=/usr/local/Cellar/ ....
    

    So I tried logging in as the username specified in the mysql_install_db output and was successful e.g.

    mysql -u jonny
    

    Then at the mysql prompt if you want to set a password for the root user:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('ToPsEcReT');
    

提交回复
热议问题