How to find out the MySQL root password

后端 未结 17 2349
野趣味
野趣味 2020-11-29 15:29

I cannot figure out my MySQL root password; how can I find this out? Is there any file where this password is stored?

I am following this link but I do not have dir

相关标签:
17条回答
  • 2020-11-29 16:12

    MySQL 5.7 and above saves root in MySQL log file.

    Please try this:

    sudo grep 'temporary password' /var/log/mysqld.log
    
    0 讨论(0)
  • 2020-11-29 16:13

    This worked for me:

    On terminal type the following

    $ sudo mysql -u root -p

    Enter password://just press enter

    mysql>

    0 讨论(0)
  • 2020-11-29 16:23

    The default password which worked for me after immediate installation of mysql server is : mysql

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

    Follow these steps to reset password in Windows system

    1. Stop Mysql service from task manager

    2. Create a text file and paste the below statement

    MySQL 5.7.5 and earlier:

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


    MySQL 5.7.6 and later:

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

    1. Save as mysql-init.txt and place it in 'C' drive.

    2. Open command prompt and paste the following

    C:\> mysqld --init-file=C:\\mysql-init.txt

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

    Unless the package manager requests you to type the root password during installation, the default root password is the empty string. To connect to freshly installed server, type:

    shell> mysql -u root --password=
    mysql>
    

    To change the password, get back the unix shell and type:

    shell> mysqladmin -u root --password= password root
    

    The new password is 'root'. Now connect to the server:

    shell> mysql -u root --password=
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    

    Oops, the password has changed. Use the new one, root:

    shell> mysql -u root --password=root
    ...
    blah, blah, blah : mysql welcome banner
    ...
    mysql> 
    

    Bingo! New do something interesting

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set (0.00 sec)
    

    Maurycy

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