How to change the MySQL root account password on CentOS7?

前端 未结 7 762
故里飘歌
故里飘歌 2020-12-12 08:58

I have installed mySQL on a Centos7 vm but I have problems logging in with root. I tried logging in without password or tried any default ones (like mysql, admin etc) I look

7条回答
  •  清歌不尽
    2020-12-12 09:13

    For me work like this: 1. Stop mysql: systemctl stop mysqld

    1. Set the mySQL environment option systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

    2. Start mysql usig the options you just set systemctl start mysqld

    3. Login as root mysql -u root

    4. After login I use FLUSH PRIVILEGES; tell the server to reload the grant tables so that account-management statements work. If i don't do that i receive this error trying to update the password: "Can't find any matching row in the user table"

提交回复
热议问题