之后我的巨大硬盘崩溃了(这与 Debian 的 LVM 更新有关,而不是硬件)我面临下一个问题:我尝试在崩溃后重新安装 mysql,并dpkg --ignore-depends ... --purge mysql-...
在机器上执行了此操作。没有更多的 MySQL,只有依赖包:
kermit:~# dpkg -l | grep -i mysql
ii courier-authlib-mysql
ii libdbd-mysql-perl
ii libpam-mysql
ii php5-mysql
ii postfix-mysql
ii proftpd-mod-mysql
没有运行的 mysql 进程,没有 /var/lib/mysql 之类的目录,什么都没有。基本上(我是这样认为的)mysql 的全新安装。但事实并非如此。一步一步:
kermit:/var/cache/apt/archives# ls mysql-*
mysql-client_5.1.43-0.dotdeb.1_all.deb mysql-common_5.1.43-0.dotdeb.1_all.deb mysql-server-5.1_5.1.43-0.dotdeb.1_i386.deb
mysql-client-5.1_5.1.43-0.dotdeb.1_i386.deb mysql-server_5.1.43-0.dotdeb.1_all.deb
kermit:/var/cache/apt/archives# dpkg -i mysql-*.deb
[...]
Stopping MySQL database server: mysqld.
100204 19:37:47 [Note] Plugin 'FEDERATED' is disabled.
100204 19:37:47 InnoDB: Started; log sequence number 0 44233
ERROR: 1146 Table 'mysql.user' doesn't exist
100204 19:37:47 [ERROR] Aborting
100204 19:37:47 InnoDB: Starting shutdown...
100204 19:37:53 InnoDB: Shutdown completed; log sequence number 0 44233
100204 19:37:53 [Note] /usr/sbin/mysqld: Shutdown complete
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
invoke-rc.d: initscript mysql, action "start" failed.
[...]
砰!不好。只有空文件,/var/log/mysql/
什么都没有/var/log/mysql.*
。但是,看,有/var/log/daemon.log
:
Feb 4 19:38:13 kermit mysqld_safe: Starting mysqld daemon with databases from /var/lib/mysql
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 [Note] Plugin 'FEDERATED' is disabled.
Feb 4 19:38:13 kermit mysqld: /usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 InnoDB: Started; log sequence number 0 44233
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 [ERROR] Can't start server : Bind on unix socket: Permission denied
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 [ERROR] Aborting
Feb 4 19:38:13 kermit mysqld:
Feb 4 19:38:13 kermit mysqld: 100204 19:38:13 InnoDB: Starting shutdown...
Feb 4 19:38:18 kermit mysqld: 100204 19:38:18 InnoDB: Shutdown completed; log sequence number 0 44233
Feb 4 19:38:18 kermit mysqld: 100204 19:38:18 [Note] /usr/sbin/mysqld: Shutdown complete
Feb 4 19:38:18 kermit mysqld:
Feb 4 19:38:18 kermit mysqld_safe: mysqld from pid file /var/run/mysqld/mysqld.pid ended
Feb 4 19:38:27 kermit /etc/init.d/mysql[9108]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Feb 4 19:38:27 kermit /etc/init.d/mysql[9108]: ^G/usr/bin/mysqladmin: connect to server at 'localhost' failed
Feb 4 19:38:27 kermit /etc/init.d/mysql[9108]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Feb 4 19:38:27 kermit /etc/init.d/mysql[9108]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Feb 4 19:38:27 kermit /etc/init.d/mysql[9108]:
嗯,那里确实没有文件:
kermit:~# ls -larth /var/lib/mysql/ /var/lib/mysql/mysql/
/var/lib/mysql/mysql/:
insgesamt 0
drwx------ 2 mysql mysql 48 4. Feb 19:38 .
drwx------ 3 mysql mysql 192 4. Feb 19:38 ..
/var/lib/mysql/:
insgesamt 21M
-rw-rw---- 1 mysql mysql 5,0M 4. Feb 19:35 ib_logfile1
-rw-r--r-- 1 mysql mysql 0 4. Feb 19:37 debian-5.1.flag
drwxr-xr-x 42 root root 1,1K 4. Feb 19:37 ..
drwx------ 2 mysql mysql 48 4. Feb 19:38 mysql
drwx------ 3 mysql mysql 192 4. Feb 19:38 .
-rw-rw---- 1 mysql mysql 5,0M 4. Feb 19:38 ib_logfile0
-rw-rw---- 1 mysql mysql 10M 4. Feb 19:38 ibdata1
更多目录:
kermit:/etc/mysql# ls -larth /var/run/mysqld/
insgesamt 512
drwxr-xr-x 13 root root 672 4. Feb 19:35 ..
drwxr-xr-x 2 mysql root 48 4. Feb 19:35 .
kermit:~# ls -larth /var/log/mysql*
-rw-r----- 1 mysql adm 0 4. Feb 19:37 /var/log/mysql.log
-rw-r----- 1 mysql adm 0 4. Feb 19:37 /var/log/mysql.err
/var/log/mysql:
insgesamt 4,0K
drwxr-xr-x 15 root root 4,3K 4. Feb 19:35 ..
drwxr-s--- 2 mysql adm 48 4. Feb 19:35 .
配置:
kermit:/etc/mysql# grep -v ^# my.cnf | grep -v "^$"
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
bind-address = 127.0.0.1
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
expire_logs_days = 10
max_binlog_size = 100M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
!includedir /etc/mysql/conf.d/
有人知道吗?
谢谢!
答案1
有几种方法可以解决这个问题:
根据 mysql 文档使用通用方法设置 mysql 服务器,但要适应任何 Debian 特性。它将涉及运行 mysql_install_db(可能带有--user=
和--datadir=
以防万一)并在尝试启动服务之前设置相关目录的权限。
或者
尝试修复 Debian 创建的安装,可能要从头开始,确保所有问题都已解决,没有相关进程仍在运行,然后重新获取您需要的软件包及其依赖项。我不是 Debian 的用户,但我倾向于让您的软件包管理器进行依赖项解析,而不是将一系列 .deb 文件交给 dpkg。(apt-get install mysql-server
,如果我没记错的话)。
答案2
将 /var/lib/mysql/ 移动到 /var/lib/mysql.bad 并重试安装。dpkg 可能会重新安装所有数据库。
您也许应该删除这些软件包,因为重新安装......
答案3
更新 mysql 后我遇到了这个问题。
我做到了:
mysqlcheck --all-databases --repair -u root -p
mysql_upgrade -u root -p
但就你的情况而言,你可能必须在重新安装之前清空 /var/lib/mysql/*,因为它将事务日志保存在里面