MySQL root password change

前端 未结 22 2814
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 18:30

I have been trying to reset my MySQL root password. I have run the mysqld_safe --skip-grant-tables, updated the root password, and checked the user table to make sure it is

相关标签:
22条回答
  • 2020-11-29 18:48

    have a look at this from MySQL Reference manual:

    First login mysql:

    # mysql -u root -p
    

    Then at mysql prompt run:

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    

    Then

    FLUSH PRIVILEGES;
    

    Look at this page for more information: Resetting the Root Password: Unix Systems

    0 讨论(0)
  • 2020-11-29 18:48
    1. On Mac open system preferences> MySQL.
    2. In the configuration section of MySQL check for initialize database.
    3. change the password in the prompt.
    0 讨论(0)
  • 2020-11-29 18:49

    a common error i run into from time to time, is that i forget the -p option, so are you sure you used:

    mysql -u root -p
    
    0 讨论(0)
  • 2020-11-29 18:50

    Tried the answer from @kta but didn't work for me.

    I am using MySQL 8.0

    This worked for me:

    mysql> SET PASSWORD FOR 'root'@'localhost' = 'yourpassword'

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

    Or just use interactive configuration:

    sudo mysql_secure_installation
    
    0 讨论(0)
  • 2020-11-29 18:52

    You have to reset the password! steps for mac osx(tested and working) and ubuntu

    Stop MySQL

    $ sudo /usr/local/mysql/support-files/mysql.server stop
    

    Start it in safe mode:

    $ sudo mysqld_safe --skip-grant-tables
    

    (above line is the whole command)

    This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:

    $ mysql -u root
    
    mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    

    Start MySQL

    sudo /usr/local/mysql/support-files/mysql.server start
    

    your new password is 'password'.

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