MacOSX homebrew mysql root password

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

    Iam using Catalina and use this mysql_secure_installation command and now works for me:

    $ mysql_secure_installation
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we'll need the current
    password for the root user. If you've just installed MariaDB, and
    haven't set the root password yet, you should just press enter here.
    
    Enter current password for root (enter for none): << enter root here >>
    

    i enter root as current password

    OK, successfully used password, moving on...
    
    Setting the root password or using the unix_socket ensures that nobody
    can log into the MariaDB root user without the proper authorisation.
    

    and do the rest

    0 讨论(0)
  • 2020-12-04 06:04

    This worked for me. Hopefully this works for you too!!! Follow them.

    brew services stop mysql
    pkill mysqld
    # NB: the following command will REMOVE all your databases!
    # Make sure you have backups or SQL dumps if you have important data in them already.
    rm -rf /usr/local/var/mysql/
    brew services restart mysql
    
    mysql -uroot
    UPDATE mysql.user SET authentication_string=null WHERE User='root';
    FLUSH PRIVILEGES;
    exit;
    
    mysql -u root 
    ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password 
    BY'YOUR_PASS_WORD!!!!';
    
    0 讨论(0)
  • 2020-12-04 06:06
    1. go to apple icon --> system preferences
    2. open Mysql
    3. in instances you will see "initialize Database"
    4. click on that
    5. you will be asked to set password for root --> set a strong password there
    6. use that password to login in mysql from next time

    Hope this helps.

    0 讨论(0)
  • 2020-12-04 06:06

    The default password when you install mysql via brew is root try this, it worked for me

    mysql -uroot -proot

    0 讨论(0)
  • 2020-12-04 06:06

    Terminal 1:

    $ mysql_safe
    

    Terminal 2:

    $ mysql -u root
    mysql> UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    
    0 讨论(0)
  • 2020-12-04 06:11

    Just run this command (where NEWPASS is your password):

    $(brew --prefix mysql)/bin/mysqladmin -u root password NEWPASS
    

    I have had the same error and fixed it this way.

    0 讨论(0)
提交回复
热议问题