Mysql
 SQL >> Database >  >> RDS >> Mysql

Impossibile accedere a mysql 5.7.9 dopo il cambio password

Due cose sono cambiate rispetto alle versioni precedenti di mySQL (io sto usando la 5.7.10):

  1. Ora si usa systemd per gestire mySQL al posto di mysqld_safe (ecco perché ottenevo l'errore -bash: mysqld_safe: command not found: non è installato)

  2. La struttura della tabella user è cambiata.

Quindi, per reimpostare la password di root, avvii comunque mySQL con le opzioni --skip-grant-tables e aggiorni la tabella user, ma il modo in cui lo fai è cambiato.

1. Stop mysql: systemctl stop mysqld 2. Set the mySQL environment option systemctl set-environment MYSQLD_OPTS="--skip-grant-tables" 3. Start mysql usig the options you just set systemctl start mysqld 4. Login as root mysql -u root 5. Update the root user password with these mysql commands mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') -> WHERE User = 'root' AND Host = 'localhost'; mysql> FLUSH PRIVILEGES; mysql> quit 6. Stop mysql systemctl stop mysqld 7. Unset the mySQL envitroment option so it starts normally next time systemctl unset-environment MYSQLD_OPTS 8. Start mysql normally: systemctl start mysqld Try to login using your new password: 7. mysql -u root -p 

Riferimento

Come si legge su https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html,

Che rimanda a https://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html, dove si menziona systemctl set-environment MYSQLD_OPTS= verso il fondo della pagina.

I comandi per la reimpostazione della password sono in fondo a https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html