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