I am new to Ubuntu. I am running Ubuntu 12.10. I am trying to install apache,php,mysql. However I have installed apache and it is running perfectly.

sudo apt-get install apache2

But when I tried to install mysql using following command

sudo apt-get install mysql-server 

After download, it asked for password but after entering and confirming password. I get following error message.

Unable to set password for the Mysql "root" user

An error occurred while setting password for the mysql
administrative user.This may have happened because the account already has a password, or because of a communication problem with the Mysql server.
You should check the account's password after the package installation.
Please read the /usr/share/doc/mysql-server-5.5/README.Debian file for more information.

after clicking on the ok button on the prompt I am getting following message on terminal

Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Mysql error log says

130209 14:26:37 [Note] Plugin 'FEDERATED' is disabled.
130209 14:26:37 InnoDB: The InnoDB memory heap is disabled
130209 14:26:37 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130209 14:26:37 InnoDB: Compressed tables use zlib 1.2.7
130209 14:26:37 InnoDB: Using Linux native AIO
mysqld: Can't create/write to file '/tmp/ibNuz7q0' (Errcode: 13)
130209 14:26:37  InnoDB: Error: unable to create temporary file; errno: 13
130209 14:26:37 [ERROR] Plugin 'InnoDB' init function returned error.
130209 14:26:37 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130209 14:26:37 [ERROR] Unknown/unsupported storage engine: InnoDB
130209 14:26:37 [ERROR] Aborting

I have searched for this problem, but nothing worked for me. Please help.

  • 1
    Check if you have mysql-server already installed by running ps -e | grep mysqld. If you see any output that means that it is already installed. – green Feb 9 '13 at 8:04
  • I am not getting any output for this – Devendra Verma Feb 9 '13 at 8:17
  • The mysql error that you posted could indicate a problem with your /etc/mysql/my.cnf. If you modified that file or any file in the /etc/mysql directory, restore the originals and try again. – Richard Ayotte Feb 10 '13 at 14:49
  • Nathan, I'm facing the same problem in this post and I've already followed the same instructions as green7 posted and yours too. I can't even understand why mysql stopped working. I'd be happy if you could give me further assistance. Edit: Just to let you know that all of that happened because I began receiving from nowhere the following message when I try to install mysql: ERROR: 1146 Table 'mysql.user' doesn't exist Thanks in advance. – user156280 May 7 '13 at 1:01
  • cannot answer due to low reputation. This gist works for me gist.github.com/ervinb/63138a504da11a9c27af – gayavat Apr 25 '16 at 10:51

Same root password setting problem here, mine possibly caused by an unsuccessful manual installation of mysql server 5.6 previously. A thorough mysql uninstallation is no easy task. I purged/reinstalled for hours then finally solved it with

sudo dpkg --purge mysql-client-core-5.5 # or alternative version
sudo dpkg --purge mysql-client
sudo dpkg --purge mysql-server-core-5.5 # or alternative version
sudo dpkg --purge mysql-common

Basically I just type

sudo dpkg --purge mysql # followed by two tabs

Then --purge any packages the terminal auto-completes. Purge mysql-common at last because of some dependency problems.

Use above dpkg commands in addition to

sudo apt-get --purge remove mysql-server
sudo apt-get --purge remove mysql-client
sudo apt-get --purge remove mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

Also I tried Greq's method

sudo rm -rf /etc/mysql

Remove the mysql folder from /var/lib

sudo rm -rf /var/lib/mysql/

At this point, to make sure mysql is fully removed, check with

which mysql
mysql --version

The first one should return no output instead of a folder. The second should return mysql is not installed instead of a version number. Otherwise the removal is still incomplete.

The significance of dpkg --purge is, when using apt-get alone, which mysql and mysql --version behave like mysql is still there.

Before reinstallation, reconfigure dpkg and update

sudo dpkg --configure -a
sudo apt-get update

Problem resolved finally. Hope it will be helpful for other people.

  • it worked..thanks a ton!!!! – huzefam Apr 11 '14 at 7:08
  • 3
    In my case,when: sudo dpkg --purge mysql-common It fails with: dpkg: dependency problems prevent removal of mysql-common: mysql-client-5.5 depends on mysql-common (>= 5.5.35-0ubuntu0.12.04.2). libmysqlclient18 depends on mysql-common (>= 5.5.35-0ubuntu0.12.04.2). dpkg: error processing mysql-common (--purge): dependency problems - not removing Errors were encountered while processing: mysql-common – ses Apr 15 '14 at 19:33
  • This also worked for me. – Michael Lindman Sep 12 '14 at 9:25
  • I've been searching for some time for a set of instructions which would fully resolve the situation. This worked just as described. Thanks. – Matt Setter Dec 5 '14 at 12:26
  • Worked for me thanks man! It's a pity that linux does such a messy job with files placement! – southerton Oct 9 '15 at 10:32

You need to completely remove mysql. Believe me, I tryied. dpkg will not do this alone.



If you are in a hurry

sudo service mysql stop  #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5.5
  • You sir, are a hero! I spent hours googling and trying the different advices everywhere, and only yours did actually work! I think the difference resides in deleting the mysql user, as I tried most of the other options already. PS: I had to kill -9 several processes before running the deluser mysql command successfully. – Shautieh Oct 28 '16 at 15:26

I think the reason is that mysql is not able to access your /tmp/ directory, as it says in the line

mysqld: Can't create/write to file '/tmp/ibNuz7q0' (Errcode: 13)

Run the following commands in a terminal:

sudo su
chown root:root /tmp
chmod 1777 /tmp
/usr/sbin/mysqld &


  • sudo su : To run the following commands as root.
  • chown root:root /tmp : Make the user root of root group the owner of /tmp.
  • chmod 1777 /tmp : Change the permissions of /tmp so that it is accessable to all the users and only the owner or the root can delete the files in that directory. (More on file permissions here)
  • /usr/sbin/mysqld & : Start the mysqld daemon.
  • after entering last command i am getting this message # /etc/init.d mysqld start bash: /etc/init.d: Is a directory – Devendra Verma Feb 9 '13 at 13:25
  • modified the answer – green Feb 9 '13 at 13:53
  • I am getting this output after /usr/sbin/mysqld & /usr/sbin/mysqld & [1] 3497 . How do I check if mysql is running – Devendra Verma Feb 10 '13 at 7:06
  • To check if your mysql is running, run ps -e | grep mysqld and if you get some output, it is running fine. – green Feb 10 '13 at 7:48
  • thanks @green7 here is the output ps -e | grep mysqld 1075 ? 00:00:04 mysqld – Devendra Verma Feb 10 '13 at 8:02

I wrestled for several hours last night with this, and read everything that Google has in its index about the problem.

I re-installed mysql 20 times. That's probably a literal figure.

Finally, one of these, or both of them, fixed the problem (after uninstalling/purging/burning mysql):

  1. sudo rm -rf /etc/mysql (this wasn't removed after the purge)
  2. I then shutdown the server and resized my VM instance from 512MB to 1GB (RAM).

Afterwards, I ran sudo aptitude install mysql-server and it finally installed successfully:

$ sudo aptitude install mysql-server
[sudo] password for [REDACTED]: 
The following NEW packages will be installed:
  libdbd-mysql-perl{a} libmysqlclient18{a} mysql-client-5.5{a} mysql-common{a} mysql-server mysql-server-5.5{a} mysql-server-core-5.5{a} 
0 packages upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,589 kB of archives. After unpacking 94.6 MB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://ftp.us.debian.org/debian/ wheezy/main mysql-common all 5.5.31+dfsg-0+wheezy1 [85.3 kB]
Get: 2 http://ftp.us.debian.org/debian/ wheezy/main libmysqlclient18 amd64 5.5.31+dfsg-0+wheezy1 [687 kB]
Get: 3 http://ftp.us.debian.org/debian/ wheezy/main libdbd-mysql-perl amd64 4.021-1+b1 [126 kB]
Get: 4 http://ftp.us.debian.org/debian/ wheezy/main mysql-client-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1,923 kB]
Get: 5 http://ftp.us.debian.org/debian/ wheezy/main mysql-server-core-5.5 amd64 5.5.31+dfsg-0+wheezy1 [3,784 kB]
Get: 6 http://ftp.us.debian.org/debian/ wheezy/main mysql-server-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1,900 kB]
Get: 7 http://ftp.us.debian.org/debian/ wheezy/main mysql-server all 5.5.31+dfsg-0+wheezy1 [83.6 kB]
Fetched 8,589 kB in 2s (3,068 kB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 52430 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_5.5.31+dfsg-0+wheezy1_all.deb) ...
Selecting previously unselected package libmysqlclient18:amd64.
Unpacking libmysqlclient18:amd64 (from .../libmysqlclient18_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Selecting previously unselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.021-1+b1_amd64.deb) ...
Selecting previously unselected package mysql-client-5.5.
Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Selecting previously unselected package mysql-server-core-5.5.
Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.5.31+dfsg-0+wheezy1) ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 52616 files and directories currently installed.)
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.5.31+dfsg-0+wheezy1_all.deb) ...
Processing triggers for man-db ...
Setting up libmysqlclient18:amd64 (5.5.31+dfsg-0+wheezy1) ...
Setting up libdbd-mysql-perl (4.021-1+b1) ...
Setting up mysql-client-5.5 (5.5.31+dfsg-0+wheezy1) ...
Setting up mysql-server-core-5.5 (5.5.31+dfsg-0+wheezy1) ...
Setting up mysql-server-5.5 (5.5.31+dfsg-0+wheezy1) ...
Stopping MySQL database server: mysqld.
131124 15:39:56 [Note] Plugin 'FEDERATED' is disabled.
131124 15:39:56 InnoDB: The InnoDB memory heap is disabled
131124 15:39:56 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131124 15:39:56 InnoDB: Compressed tables use zlib 1.2.7
131124 15:39:56 InnoDB: Using Linux native AIO
131124 15:39:56 InnoDB: Initializing buffer pool, size = 128.0M
131124 15:39:56 InnoDB: Completed initialization of buffer pool
131124 15:39:56 InnoDB: highest supported file format is Barracuda.
131124 15:39:56  InnoDB: Waiting for the background threads to start
131124 15:39:57 InnoDB: 5.5.31 started; log sequence number 1595675
131124 15:39:57  InnoDB: Starting shutdown...
131124 15:39:58  InnoDB: Shutdown completed; log sequence number 1595675
Starting MySQL database server: mysqld ..
Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly..
Setting up mysql-server (5.5.31+dfsg-0+wheezy1) ...

Type sudo apt-get purge mysql-server && sudo apt-get install mysql-server if that does not work please leave a comment on my answer and I will work with you to solve this issue.

The install scripts for all Ubuntu versions after 12.04 do not follow the same setup process as 12.04. In 12.04 you are explicitly asked to set the mysql password during the installation. For 12.10 and after it simply asks for the mysql root password, but what is that password? The install script is a step backward. I recommend installing 12.04 in a virtual machine and installing mysql there. If you are like me and using this in conjunction with Drupal definitely stick to 12.04.

Different solution for those still having issues. Hopefully I can help those trying to reinstall Mysql. Note, It's a seek and destroy mission. So be weary. Assuming your root:

apt-get purge mysql*
apt-get purge dbconfig-common #the screen used for mysql password
find / -name *mysql*          #delete any traces of mysql
#insert apt-get cleanups, autoremove,updates etc.

Originally, something leftover was interfering with my startup of mysqlserver-5.5. These commands ended up resolving the issue for myself.

protected by Community Sep 17 '15 at 20:56

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

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.