Reset MySQL root password using ALTER USER statement after install on Mac

后端 未结 19 2055
慢半拍i
慢半拍i 2020-11-29 14:21

I\'m new to the whole Mac experience. I recently installed MySQL and it seems I have to reset the password after install. It won\'t let me do anything else.

Now I al

相关标签:
19条回答
  • 2020-11-29 15:14

    Mysql 5.7.24 get root first login

    step 1: get password from log

     grep root@localhost /var/log/mysqld.log
        Output
            2019-01-17T09:58:34.459520Z 1 [Note] A temporary password is generated for root@localhost: wHkJHUxeR4)w
    

    step 2: login with him to mysql

    mysql -uroot -p'wHkJHUxeR4)w'
    

    step 3: you put new root password

    SET PASSWORD = PASSWORD('xxxxx');
    

    you get ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

    how fix it?

    run this SET GLOBAL validate_password_policy=LOW;

    Try Again SET PASSWORD = PASSWORD('xxxxx');

    0 讨论(0)
  • 2020-11-29 15:18

    Run these:

    $ cd /usr/local/mysql/bin
    $ ./mysqladmin -u root password 'password'
    

    Then run

    ./mysql -u root
    

    It should log in. Now run FLUSH privileges;

    Then exit the MySQL console and try logging in. If that doesn't work run these:

    $ mysql -u root
    mysql> USE mysql;
    mysql> UPDATE user SET authentication_string=PASSWORD("XXXXXXX") WHERE User='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    

    Change xxxxxx to ur new password. Then try logging in again.

    Update. See this http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

    It should solve your problem.

    If you are on oracle try this

    ALTER USER username IDENTIFIED BY password
    
    0 讨论(0)
  • 2020-11-29 15:18

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

    Use this line...

    0 讨论(0)
  • 2020-11-29 15:19

    UPDATE user SET authentication_string=PASSWORD("MyPassWord") WHERE User='root'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '("MyPassWord") WHERE User='root'' at line 1

    Resolved with

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    

    Reference from below site

    https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html

    0 讨论(0)
  • 2020-11-29 15:22

    Maybe try that ?

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

    or

    SET PASSWORD FOR 'root'@'%' = PASSWORD('XXX');
    

    Depending on which access you use.

    (and not sure you should change yourself field names...)

    https://dev.mysql.com/doc/refman/5.0/en/set-password.html

    0 讨论(0)
  • 2020-11-29 15:24

    in 5.7 version. 'password' field has been deleted. 'authentication_string' replace it

    use mysql;
    update user set authentication_string=password('123456') where user='root';
    flush privileges;
    
    0 讨论(0)
提交回复
热议问题