1

Ubuntu Server 14.04, everything on the server is fully updated. No matter what I try, I cannot get mysql-server to install. I followed all answers to this question, and I even tried sudo apt-get purge mysql.*. Nothing works. What's going on?

Error I get:

Selecting previously unselected package mysql-server-core-5.5.
Preparing to unpack .../mysql-server-core-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-server-core-5.5 (5.5.49-0ubuntu0.14.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up mysql-common (5.5.49-0ubuntu0.14.04.1) ...
(Reading database ... 110435 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb ...
You are required to change your password immediately (root enforced)
chfn: PAM: Authentication token is no longer valid; new one required
adduser: `/usr/bin/chfn -f MySQL Server mysql' returned error code 1. Exiting.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.5_5.5.49-0ubuntu0.14.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
  • Hmm... I wonder if at some point you created a regular user account with the username mysql, which is interfering with the creation of a mysql system user? What does getent passwd mysql say? – steeldriver Jul 15 '16 at 19:56
  • @steeldriver mysql:x:106:114::/nonexistent:/bin/false I did delete the user each time before I ran apt-get install. – vaindil Jul 15 '16 at 22:05
1

Try with

sudo dpkg -l | grep mysql 

It will list the packages belonging to the mysql.

Then try the following command 

sudo apt-get --purge autoremove mysql*
sudo apt-get autoclean 

After that

sudo rm -r /var/lib/mysql
sudo rm -r /etc/mysql

After the above steps try installing mysql again.

| improve this answer | |
0

After performing the above steps, please follow below steps.

sudo apt-get update
sudo apt-get install mysql-server
sudo apt-get update
sudo apt-get install mysql-server-5.6
sudo mysql_secure_installation
mysql --version
| improve this answer | |
0

If you're trying to install this in noninteractive mode, like in a Dockerfile, try this:

DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server mysql-client

| improve this answer | |
0

The important part of the log you listed is:

You are required to change your password immediately (root enforced)
chfn: PAM: Authentication token is no longer valid; new one required
adduser: `/usr/bin/chfn -f MySQL Server mysql' returned error code 1. Exiting.

It's a bit confusing because it's happening during installation of MySQL, but what this is trying to explain is that your root account for Ubuntu (not MySQL) needs to be changed. I was turned on to this by a similar error in a bug report on GitHub.

You can verify that this is the issue with sudo chage -l root (yes, chage). You'll see something like:

Last password change                              : password must be changed
Password expires                                  : password must be changed
Password inactive                                 : password must be changed
Account expires                                   : never
Minimum number of days between password change    : 0
Maximum number of days between password change    : 14600
Number of days of warning before password expires : 14

You need to reset the root password with chpasswd "root:YOURPASSWORD". (You can generate a random hex password with $(openssl rand -hex 32).)

You should now see something like:

Last password change                              : Oct 17, 2018
Password expires                                  : never
Password inactive                                 : never
Account expires                                   : never
Minimum number of days between password change    : 0
Maximum number of days between password change    : 14600
Number of days of warning before password expires : 14

And you should be able to install MySQL successfully now!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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