sudo apt-get install mysql-server 失败

sudo apt-get install mysql-server 失败

我刚刚安装了 Ubuntu 服务器 9.10,并尝试使用“sudo apt-get mysql-server”安装 mysql-server

我得到以下错误:
dan@dev:~$ sudo apt-get install mysql-server
[sudo] dan 的密码:
正在读取软件包列表... 完成 正在
构建依赖关系树
正在读取状态信息... 完成
将安装以下额外软件包:
libdbd-mysql-perl libdbi-perl libhtml-template-perl
libnet-daemon-perl libplrpc-perl mysql-client-5.1
mysql-server-5.1
建议的软件包:
dbishell libipc-sharedcache-perl tinyca
将安装以下新软件包:
libdbd-mysql-perl libdbi-perl libhtml-template-perl
libnet-daemon-perl libplrpc-perl mysql-client-5.1
mysql-server mysql-server-5.1
升级了 0 个软件包,新安装了 8 个软件包,要删除 0 个软件包,未升级 0 个软件包。需要获取 16.5MB 的档案。
此操作后,将使用 39.0MB 的额外磁盘空间。
您想继续吗 [Y/n]? y
获取:1http://us.archive.ubuntu.comkarmic/main libnet-daemon-perl 0.43-1 [46.9kB]
获取:2http://us.archive.ubuntu.comkarmic/main libplrpc-perl 0.2020-2 [36.0kB]
获取:3http://us.archive.ubuntu.comkarmic/main libdbi-perl 1.609-1 [800kB]
获取:4http://us.archive.ubuntu.comkarmic/main libdbd-mysql-perl 4.011-1ubuntu1 [136kB]
获取:5http://us.archive.ubuntu.comkarmic-updates/main mysql-client-5.1 5.1.37- 1ubuntu5.1 [8,202kB]
获取:6http://us.archive.ubuntu.comkarmic-updates/main mysql-server-5.1 5.1.37-1ubuntu5.1 [7,186kB]
获取:7http://us.archive.ubuntu.comkarmic/main libhtml-template-perl 2.9-1 [65.8kB]
获取:8http://us.archive.ubuntu.comkarmic-updates/main mysql-server 5.1.37-1ubuntu5.1 [64.3kB]
已提取 16.5MB,耗时 1分 34秒 (175kB/s)
正在预配置软件包...
正在选择先前取消选择的软件包 libnet-daemon-perl。
(正在读取数据库... 当前安装了 123083 个文件和目录。)
正在解压 libnet-daemon-perl(来自.../libnet-daemon-perl_0.43-1_all.deb)...
正在选择先前取消选择的软件包 libplrpc-perl。
正在解压 libplrpc-perl(来自.../libplrpc-perl_0.2020-2_all.deb)...
正在选择先前取消选择的软件包 libdbi-perl。
正在解压 libdbi-perl(来自 .../libdbi-perl_1.609-1_i386.deb)...
正在选择以前取消选择的软件包 libdbd-mysql-perl。
正在解压 libdbd-mysql-perl(来自 .../libdbd-mysql-perl_4.011-1ubuntu1_i386.deb)...
正在选择以前取消选择的软件包 mysql-client-5.1。
正在解压 mysql-client-5.1(来自 .../mysql-client-5.1_5.1.37-1ubuntu5.1_i386.deb)...
正在选择以前取消选择的软件包 mysql-server-5.1。
正在解压 mysql-server-5.1(来自 .../mysql-server-5.1_5.1.37-1ubuntu5.1_i386.deb)...
正在选择以前取消选择的软件包 libhtml-template-perl。正在解压 libhtml-template-perl(来自 .../libhtml-template-perl_2.9-1_all.deb)...
正在选择先前取消选择的软件包 mysql-server。
正在解压 mysql-server(来自 .../mysql-server_5.1.37-1ubuntu5.1_all.deb)...
正在处理 man-db 触发器...
正在处理 ureadahead 触发器...
ureadahead 将在下次重启时重新配置
设置 libnet-daemon-perl(0.43-1)...
正在设置 libplrpc-perl(0.2020-2)...
正在设置 libdbi-perl(1.609-1)...
正在设置 libdbd-mysql-perl(4.011-1ubuntu1)...
正在设置 mysql-client-5.1(5.1.37-1ubuntu5.1)...

Setting up mysql-server-5.1 (5.1.37-1ubuntu5.1) ...  
 * Stopping MySQL database server mysqld                [ OK ]   
 * Starting MySQL database server mysqld                [fail]   
invoke-rc.d: initscript mysql, action "start" failed.           
dpkg: error processing mysql-server-5.1 (--configure):         
subprocess installed post-installation script returned error exit status 1                                                   
Setting up libhtml-template-perl (2.9-1) ...                   
dpkg: dependency problems prevent configuration of mysql-server:                                                              
mysql-server depends on mysql-server-5.1; however:            
Package mysql-server-5.1 is not configured yet.              
dpkg: error processing 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.1
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

我错过了什么?

[更新] mysqld 返回:

dan@dev:~$ sudo mysqld                                                                           
[sudo] password for dan:                                                                         
100220 12:18:17 [Note] Plugin 'FEDERATED' is disabled.                                           
InnoDB: Unable to lock ./ibdata1, error: 11                                                      
InnoDB: Check that you do not already have another mysqld process                                
InnoDB: using the same InnoDB data or log files.                                                 
100220 12:18:17  InnoDB: Retrying to lock the first data file                                    
InnoDB: Unable to lock ./ibdata1, error: 11                                                      
InnoDB: Check that you do not already have another mysqld process                                

这种情况持续了一段时间...

InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
^[[BInnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
100220 12:19:57  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
100220 12:19:57  InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
100220 12:19:57 [ERROR] Plugin 'InnoDB' init function returned error.
100220 12:19:57 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
100220 12:19:57 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
100220 12:19:57 [ERROR] Do you already have another mysqld server running on port: 3306 ?
100220 12:19:57 [ERROR] Aborting

100220 12:19:57 [Warning] Forcing shutdown of 1 plugins
100220 12:19:57 [Note] mysqld: Shutdown complete

我如何检查哪些进程正在使用端口:3306?

[更新]: sudo netstat -anp | grep LISTEN
返回

dan@dev:~$ sudo netstat -anp | grep LISTEN                                                              
[sudo] password for dan:                                                                                
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1372/master     
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      4391/mysqld     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1409/cupsd      
tcp6       0      0 ::1:631                 :::*                    LISTEN      1409/cupsd      

[更多更新]:如果这有区别的话我可以登录mysql

答案1

在这种情况下,我会尝试以下方法:

尝试重新安装mysql-server-5.1:

sudo apt-get install --reinstall mysql-server-5.1

尝试重新安装 mysql-server:

sudo apt-get install --reinstall mysql-server

尝试重新配置 mysql-server-5.1 并再次尝试重新安装:

sudo dpkg-reconfigure mysql-server-5.1
sudo apt-get install --reinstall mysql-server

答案2

软件包mysql-server-5.1安装完成后,会尝试启动 MySQL,但失败了。您需要做的第一件事就是干净地完成安装过程。有几种方法可以做到这一点:

  • 修复你的 MySQL 配置,检查其是否/etc/init.d/mysql-server正常工作,然后启动dpkg --configure -a以完成安装过程;
  • 或者编辑/var/lib/dpkg/info/mysql-server-5.1.postinst并删除启动服务器的部分(可能调用/etc/init.d/mysql-server start左右),然后启动dpkg --configure -a以完成安装过程,然后修复您的配置。

答案3

尝试一下lsof -i @localhost:3306。您可能需要安装 lsof,但它是一款非常棒的工具。

相关内容