What is the default root pasword for MySQL 5.7

前端 未结 13 1203
梦谈多话
梦谈多话 2020-12-22 16:55

Cannot login to MySQL database after fresh install with root ID and empty/no password like other older MySQL versions do

13条回答
  •  攒了一身酷
    2020-12-22 17:43

    As of Ubuntu 20.04 with MySql 8.0 : you can set the password that way:

    1. login to mysql with sudo mysql -u root

    2. change the password:

    USE mysql;
    UPDATE user set authentication_string=NULL where User='root';
    FLUSH privileges;
    ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'My-N7w_And.5ecure-P@s5w0rd';
    FLUSH privileges;
    QUIT
    

    now you should be able to login with mysql -u root -p (or to phpMyAdmin with username root) and your chosen password.

    P,S:

    You can also login with user debian-sys-maint, the password is written in the file /etc/mysql/debian.cnf

提交回复
热议问题