Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am unable to install mysql-server on my ubuntu 9.10 server machine. When using apt-get install mysql-server the output is :

# apt-get install mysql-server

Reading package lists... Done
Building dependency tree
Reading state information... Done

mysql-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 120 not upgraded.
2 not fully installed or removed.

After this operation, 0B of additional disk space will be used.
Setting up mysql-server-5.1 (5.1.37-1ubuntu5.4) ...
* 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

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)

I cant find a satisfactory solution to this problem anywhere. Many sites tell to reinstall it but its not working.

Any help will be appreciated.

Thank you..

share|improve this question
    
Have tried using aptitude? aptitude install mysql-server-5.1 –  Chris_O Apr 1 '11 at 14:00
    
yeah..tried that as well, same error. –  Arihant Apr 1 '11 at 14:45

4 Answers 4

This worked for me:

apt-get purge mysql-server
apt-get purge mysql-common
rm -rf /var/log/mysql
rm -rf /var/log/mysql.*
rm -rf /var/lib/mysql
rm -rf /etc/mysql
# and then:
apt-get install mysql-server --fix-missing --fix-broken

Although it will also remove all dependencies on mysql.

Source.

share|improve this answer
    
+1 Worked fine for me too! –  Chris McCauley Dec 17 '12 at 17:12
    
Worked on Ubuntu 12.04 LTS and MySQL 5.5.34. –  Crispy Oct 25 '13 at 15:56
    
+1 worked for me too. I had tried apt-get purge mysql-server but not apt-get purge mysql-common and was not working. Thanks. –  Davide Vernizzi Apr 11 at 21:30
    
I can confirm this worked for me as well –  Florestan06 Jun 6 at 12:22

A few suggestions:

  • the ever obvious, make sure you are running as root
  • try doing apt-get remove mysql
  • then try doing an apt-get purge (you might need apt-get purge mysql, sometimes aptitude can be picky)
  • always check your logs. They will most likely hold the answer for almost everything.
  • also, try doing an apt-get clear cachce and apt-get clean. Then try installing again.

Or try this solution I found on google:

The mysql-server-5.1 package tries to start MySQL after the package is installed, which fails. The first thing you need to do is finish the installation process cleanly. There are several ways to do this:

either fix your MySQL configuration, check that /etc/init.d/mysql-server works, and launch dpkg --configure -a to finish the installation process ; or edit /var/lib/dpkg/info/mysql-server-5.1.postinst and remove the part where it starts the server (probably calling /etc/init.d/mysql-server start or so), then launch dpkg --configure -a to finish the installation process and then fix your configuration. http://www.openg.info/entry/sudo-apt-install-mysql-server-fails

share|improve this answer
1  
Agree with the advice to purge the install & retry –  jamespo Apr 1 '11 at 14:19
    
that dint work!! –  Arihant Apr 1 '11 at 15:01

MySQL failed to start. The reason this occurred should be logged in /var/log/mysql.log (or is it still /var/lib/mysql/.err?). Can you paste the output from there, and maybe we can figure out what went wrong.

share|improve this answer
    
/var/log/mysql.err and /var/log/mysql.log both files are empty. –  Arihant Apr 1 '11 at 14:52
    
Following is the output of /usr/local/mysql/clc.err file.clc is hostname 20:50:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 110402 20:50:31 [Warning] Can't create test file /var/lib/mysql/clc.lower-test 110402 20:50:31 [Warning] Can't create test file /var/lib/mysql/clc.lower-test 110402 20:50:31 [ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists! 110402 20:50:31 [ERROR] Aborting 110402 20:50:31 [Note] /usr/sbin/mysqld: Shutdown complete 110402 20:50:31 mysqld_safe mysqld from pid file /var/lib/mysql/clc.pid ended –  Arihant Apr 1 '11 at 14:59
    
Maybe 1) mysql user does not exist, or 2) /var/lib/mysql is not owned by mysql user? If 2), remember to chown -R. –  Bittrance Apr 1 '11 at 15:04
    
this is /etc/passwd file entry: 'mysql:x:118:128:MySQL Server,,,:/var/lib/mysql:/bin/false' . I have already done chown -R mysql /var/lib/mysql .. –  Arihant Apr 1 '11 at 15:08
    
This is the output of : apt-get purge mysql-server ` * Stopping MySQL database server mysqld * 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 E: Sub-process /usr/bin/dpkg returned an error code (1) ` I cant understand why is it starting the mysql-server service when i am removing it. –  Arihant Apr 1 '11 at 15:13

Open a different console, enter ps aux | grep mys

And kill anything that looks like this:

egrep -qi ... /etc/mysql/

This should allow the installation to complete.

share|improve this answer

protected by sysadmin1138 Sep 28 '12 at 21:57

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.