在经历了巨大的硬盘崩溃(与 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/
有人知道吗?
谢谢!
将您的 /var/lib/mysql/ 移动到 /var/lib/mysql.bad 并重试安装。dpkg 可能会重新安装所有数据库。
您可能应该删除软件包,因为重新安装...
我更新mysql后遇到了这个问题。
我做了:
但是在您的情况下,您可能必须在重新安装之前清空 /var/lib/mysql/* ,因为它会将事务日志保存在里面
有几种方法可以解决这个问题:
根据 mysql 文档,使用通用方法设置 mysql 服务器,但要适应任何 Debian 特性。至少在您尝试启动服务之前,它将涉及运行 mysql_install_db (可能是为了以防万一)
--user=
并设置相关目录的权限。--datadir=
或者
尝试修复 Debian 创建的安装,可能是从头开始,确保一切顺利,没有相关进程在运行,并重新获取您需要的软件包及其依赖项。我不是 Debian 的人,但我倾向于让你的包管理器做依赖解析,而不是把一系列 .debs 交给 dpkg。(
apt-get install mysql-server
,IIRC)。