MySQL 재설치

MySQL 재설치

비슷한 질문이 있지만 그 중 어느 것도 내 문제를 해결하지 못했으므로 뭔가를 놓친 경우 사과드립니다.

mysqldbcopy인스턴스에 여유 공간이 부족할 때 데이터베이스 복사본을 만드는 데 사용하고 있었습니다 . MySQL이 충돌하여 다시 시작할 수 없습니다. 공간을 확보하기 위해 /var/lib/mysql. Mysql이 여전히 다시 시작되지 않아 제거 /var/lib/mysql하고 sudo mysql_install_db. 이 방법은 효과가 있었지만 더 이상 비밀번호를 사용하거나 사용하지 않고 로그인할 수 없었고 비밀번호를 재설정할 수도 없었습니다.

마지막 시도로 방금 했어요

sudo apt-get remove --purge mysql*

하지만 다시 설치하려고 하면 다음과 같은 메시지가 나타납니다.

Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-server-core-5.7.
(Reading database ... 94735 files and directories currently installed.)
Preparing to unpack .../mysql-server-core-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server-5.7.
Preparing to unpack .../mysql-server-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.18-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.18-0ubuntu0.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up mysql-server-core-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for systemd (229-4ubuntu16) ...No apport report written because the error message indicates its a followup error from a previous failure.

Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

아이디어가 부족해요. 어떤 제안이라도 감사하겠습니다.

출력 sudo dpkg -r --force-all mysql-server mysql-server-5.7 && sudo apt install -f:

$ sudo dpkg -r --force-all mysql-server mysql-server-5.7 && sudo apt install -f
(Reading database ... 94924 files and directories currently installed.)
Removing mysql-server (5.7.18-0ubuntu0.16.04.1) ...
Removing mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Processing triggers for man-db (2.7.5-1) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5 libfcgi-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
  libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl
  mysql-server-core-5.7 python-mysql.connector
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 50 not upgraded.

출력sudo apt-get install mysql-server

$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  python-mysql.connector
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  mysql-server-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-server mysql-server-5.7
0 upgraded, 2 newly installed, 0 to remove and 50 not upgraded.
Need to get 0 B/2,565 kB of archives.
After this operation, 48.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 94847 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.18-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.18-0ubuntu0.16.04.1) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
         Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

답변1

mysqld그래서 터미널에서 실행을 해보니

mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't e$ists.

그 결과 해당 디렉토리를 만들고 권한을 업데이트하게 되었습니다. 그러면 나는 할 수 있다

sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld

그런 다음 안전 모드에서 시작할 수 있습니다.

sudo /usr/bin/mysqld_safe --skip-grant-tables &

비밀번호를 수동으로 설정하세요.

USE mysql
UPDATE mysql.user
SET authentication_string=PASSWORD('hunter4')
WHERE user='root' AND host='localhost';

관련 정보