Ubuntu – Unable to set password for the thesql “root” user

Apache2MySQLPHP

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:
mysql-server-5.5
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.

Best Answer

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.