How to find out the MySQL root password

后端 未结 17 2485
野趣味
野趣味 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:09

    one thing that tripped me up on a new install of mySQL and wonder why I couldn't get the default password to work and why even the reset methods where not working. well turns out that on Ubuntu 18 the most recent version of mysql server does not use password auth at all for the root user by default. So this means it doesn't matter what you set it to, it won't let you use it. it's expecting you to login from a privileged socket. so

    mysql -u root -p
    

    will not work at all, even if you are using the correct password!!! it will deny access no matter what you put in.

    Instead you need to use

    sudo mysql
    

    that will work with out any password. then once you in you need type in

     ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password you want to use';
    

    then log out and now the bloody thing will finally accept your password

提交回复
热议问题