MySQL을 5.6에서 5.7로 업그레이드한 후 루트 사용자로 로그인할 수 없습니다.

MySQL을 5.6에서 5.7로 업그레이드한 후 루트 사용자로 로그인할 수 없습니다.

MySQL을 5.6에서 5.7로 업그레이드한 후 루트로 로그인할 수 없습니다.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

로그에서 다음을 발견했습니다.

2016-10-26T10:23:01.845088Z 0 [Warning] User entry 'root'@'localhost' has an empty plugin value. The user will be ignored and no one can login with this user anymore.
2016-10-26T10:23:01.845112Z 0 [Warning] User entry 'mysql.sys'@'localhost' has an empty plugin value. The user will be ignored and no one can login with this user anymore.
2016-10-26T10:23:01.845127Z 0 [Warning] User entry 'debian-sys-maint'@'localhost' has an empty plugin value. The user will be ignored and no one can login with this user anymore.
2016-10-26T10:23:01.845142Z 0 [Warning] User entry 'phpmyadmin'@'localhost' has an empty plugin value. The user will be ignored and no one can login with this user anymore.
2016-10-26T10:23:01.845155Z 0 [Warning] Some of the user accounts with SUPER privileges were disabled because of empty mysql.user.plugin value. If you are upgrading from MySQL 5.6 to MySQL 5.7 it means we were not able to substitute for empty plugin column. Probably because of pre 4.1 password hash. If your account is disabled you will need to:
2016-10-26T10:23:01.845183Z 0 [Warning] 1. Stop the server and restart it with --skip-grant-tables.
2016-10-26T10:23:01.845192Z 0 [Warning] 2. Run mysql_upgrade.
2016-10-26T10:23:01.845200Z 0 [Warning] 3. Restart the server with the parameters you normally use.
2016-10-26T10:23:01.845207Z 0 [Warning] For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual
2016-10-26T10:23:01.853461Z 0 [Note] Event Scheduler: Loaded 0 events
2016-10-26T10:23:01.853962Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.16-0ubuntu0.16.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
2016-10-26T10:23:02.138961Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)

그래서 제안한 대로 했습니다. 서버를 중지합니다.

> service mysql stop

승인 양식을 건너뛰고 시작하세요.

> sudo mysqld_safe --skip-grant-tables

mysqld_safe가 --skip-grant-tables와 함께 실행되면 루트로 로그인할 수 있지만 실행 중인 터미널을 닫기 전에만 가능합니다(데몬으로 실행되지는 않지만 터미널이 닫힐 때 중지됩니다).

그런 다음 제안된 대로 mysql_upgrade를 실행했습니다(다른 터미널에서).

> sudo mysql_upgrade

이것은 내 책상을 업그레이드했습니다.

mysqld_safe를 실행하는 터미널을 닫고 mysql 서버를 중지했습니다(service mysql stop). mysql의 모든 인스턴스를 종료해야 합니다. 그렇지 않으면 다음 오류의 전체 로그가 표시됩니다.

2016-10-26T10:40:54.073975Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2016-10-26T10:40:54.074060Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

그런 다음 MySQL을 다시 시작합니다.

> service mysql start

위와 동일한 결과를 얻었습니다(사용자 "root"@"localhost"에 대한 액세스가 거부되었습니다(비밀번호 사용: NO)).

어떻게 해결할 수 있나요? 나는 몇 시간 동안 이 문제로 어려움을 겪었습니다. 어떤 도움이라도 대단히 감사하겠습니다!

답변1

Ubuntu를 14.04에서 16.04로 업그레이드할 때도 동일한 문제가 발생했습니다. 나는 당신이 제안한 것(데이터베이스를 내보내고 다시 시작)을 수행하기에는 너무 게을러서 결국 문제를 해결하기 위해 그렇게 했습니다!

mysql을 중지한 후 인증 없이 시작

> sudo service stop mysql 
> sudo mkdir /var/run/mysqld # needed to launch mysql in ubuntu from command line...may not apply to other distros
> sudo chown mysql:mysql /var/run/mysqld # same reason as above
> sudo mysqld_safe --skip-grant-tables

그런 다음 다른 터미널 창에서 다음을 수행합니다.

> mysql -uroot 
> select User, host, authentication_string,plugin from mysql.user; #see what users don't have a password (authentication_string and plugin are empty) 
> update mysql.user set authentication_string=PASSWORD('woot') where user='user';
> update mysql.user set plugin='mysql_native_password' where user='user'; 
> FLUSH PRIVILEGES;
> exit; 

마지막으로 임시 mysql(mysqld_safe) 인스턴스를 종료하고 첫 번째 터미널에서 다시 시작해야 했습니다.

> ^\ #to tell the mysqld_safe process to quit itself 
> sudo service mysqld start 

답변2

문제는 debian-sys-maint를 포함한 모든 사용자에 대해 mysql.user 플러그인 값이 비어 있어서 패키지를 재구성조차 할 수 없다는 것입니다. mysql_upgrade를 실행하여 수정해야 하지만 어떤 이유로 인해 수정되지 않습니다.

그래서 모든 데이터베이스를 덤프하고 MySQL 서버를 완전히 제거한 다음 다시 설치하고 데이터베이스를 다시 가져왔습니다.

모든 데이터베이스를 덤프합니다.

> mysqldump -u root -p --databases db1 db2 > alldb.sql

이것은 내 입장에서는 매우 어리석은 일이지만 --all-databases를 사용하여 모든 데이터베이스를 덤프했습니다. 모든 사용자에 대해 "플러그인" 값이 비어 있는 mysql.user 테이블이 포함되어 있어서 처음으로 mysql 서비스를 다시 시작한 후에도 동일한 문제가 발생했습니다. 그래서 데이터베이스에 대해서만 덤프를 수행했습니다.

덤프는 명령을 실행한 폴더에 저장됩니다.

MySQL 및 해당 설정을 삭제합니다.

> sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7
> sudo rm -rf /etc/mysql /var/lib/mysql
> sudo apt-get autoremove
> sudo apt-get autoclean

MySQL을 설치합니다:

> sudo apt-get install mysql-server

데이터베이스를 가져옵니다.

> mysql -u root -p < alldb.sql

관련 정보