3

How can I solve this problem?

root@ip-*******:/# apt-get upgrade 
Reading package lists... Done    
Building dependency tree    
Reading state information... Done    
Calculating upgrade... Done    
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.    
2 not fully installed or removed.    
After this operation, 0 B of additional disk space will be used.    
Do you want to continue? [Y/n] y    
Setting up mysql-community-server (5.7.19-1ubuntu16.04) ...    
Job for mysql.service failed because the control process exited with error code.    
See "systemctl status mysql.service" and "journalctl -xe" for details.    
invoke-rc.d: initscript mysql, action "start" failed.
    ● mysql.service - MySQL Community Server    
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor reset: enabled)    
   Active: activating (auto-restart) (Result: exit-code) since Fri 2017-09-01 12:16:18 UTC; 4ms ago    
   Main PID: 16929 (code=exited, status=0/SUCCESS)    
dpkg: error processing package mysql-community-server (--configure):    
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-community-server (= 5.7.19-1ubuntu16.04);   however:
  Package mysql-community-server is not configured yet.    
dpkg: error processing package 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-community-server
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

And also all same error.

ADD:

root@ip-172-31-15-21:/# apt-get update
Hit:1 http://security.ubuntu.com/ubuntu precise-security InRelease
Ign:2 http://archive.ubuntu.com/ubuntu precise InRelease
Ign:3 http://extras.ubuntu.com/ubuntu precise InRelease
Hit:4 http://archive.ubuntu.com/ubuntu precise Release
Hit:6 http://extras.ubuntu.com/ubuntu precise Release
Ign:7 http://archive.canonical.com/ubuntu precise InRelease
Get:8 http://extras.ubuntu.com/ubuntu precise Release.gpg [72 B]
Ign:8 http://extras.ubuntu.com/ubuntu precise Release.gpg
Hit:9 http://archive.canonical.com/ubuntu precise Release
Ign:11 http://it.archive.ubuntu.com/ubuntu precise InRelease
Hit:12 http://it.archive.ubuntu.com/ubuntu precise-updates InRelease
Hit:13 http://it.archive.ubuntu.com/ubuntu precise Release
Fetched 72 B in 2s (25 B/s)
Reading package lists... Done
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: http://archive.ubuntu.com/ubuntu/dists/precise/Release.gpg: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: GPG error: http://extras.ubuntu.com/ubuntu precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192
W: The repository 'http://extras.ubuntu.com/ubuntu precise Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: http://archive.canonical.com/ubuntu/dists/precise/Release.gpg: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: http://it.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: http://it.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6

and my sources.list enter image description here

1

9 Answers 9

11

It looks as though the installation was interrupted in an earlier session.

Try sudo apt-get install -f to see if it will fix broken dependencies.

If that fails, purge MySQL server:

sudo apt-get purge mysql-server mysql-community-server

Then clean and update:

sudo apt-get autoclean && sudo apt-get clean && sudo apt-get update

Do a general upgrade:

sudo apt-get upgrade

Now try re-installing:

sudo apt-get install mysql-server and mysql-community-server

If you are doing this from the root prompt, then you don't lead the leading sudo command.

3
  • Thank you. But there was another problem. Read the 'ADD:' section?
    – Do Yeop
    Sep 1, 2017 at 15:06
  • 1
    @DoYeop I addressed some of the errors in a separate answer because I am not sure how they relate to the initial part of the question, and it is rather lengthy besides.
    – gracious1
    Sep 1, 2017 at 16:59
  • 4
    and is actually a package in the repositories. did you mean to include it here? I'm assuming you meant sudo apt-install mysql-server mysql-community-server? Feb 18, 2020 at 0:35
1

Regarding your updated question, firstly I can see in your sources.list there are some redundancies. For example, you have this error in your output:

W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6

And you have this in line 1 in your sources file

deb http://it.archive.ubuntu.com/ubuntu precise main restricted

which is duplicated in line 6.

So to fix those errors I suggest you remove all of the duplicated lines indicated in the output. (There are a lot of them!)

Secondly, there is this error:

W: GPG error: http://extras.ubuntu.com/ubuntu precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

To fix this GNU Privacy Guard error, let's obtain that key. Run this:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192

Then fix broken dependencies by running dpkg --configure -a or apt-get install -f (or both).

and then once more:

apt-get clean && apt-get update
1

I have bumped into this myself on Ubuntu 16.04 LTS (xenial). Your MySQL log probably also has errors mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server Upgrade process encountered error and will not continue..

Here is what I have been doing to get around the issue (I have not yet debugged the real issue of why the connect fails). It's worked through the last 3 MySQL updates.

First, as root with MySQL running:

# mysql_upgrade --defaults-file=/etc/mysql/debian.cnf

This should complete with no errors.

Then edit the file /var/lib/dpkg/info/mysql-server-5.7.postinst. Somewhere around line 320 find and comment the line:

mysql_upgrade --defaults-file=/etc/mysql/debian.cnf || result=$?

Exit and save the file. Run apt-get upgrade again and it should run clean.

1

you can purge all and reinstall

fisrt of all , do a backup of your usefull databse

to purge all do this

1- basic check of DBSM:

dpkg -l | grep -e mysql-server -e mariadb-server

do this lab

kill all mysql process

sudo service mysql stop 
sudo killall -9 mysql 
sudo killall -9 mysqld


sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7  
            
sudo apt-get remove --purge mysql* 
sudo apt-get purge mysql*
sudo apt-get remove dbconfig-mysql 

sudo apt-get autoremove
sudo apt-get autoclean

remove mysql old files

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

update

sudo apt-get dist-upgrade -y
sudo apt update

then reinstall

sudo apt-get install mysql-server and mysql-community-server
1
  • 1
    Thanks a lot. Finally after long search, this worked (ubuntu 20.04)
    – Angel M.
    Jul 14, 2023 at 14:39
0

Errors indicates that you have to tried to install mysql-server but something went wrong. The problem encoutered while configuring package mysql-community-server. You can try to run:

dpkg --configure mysql-community-server

or:

dpkg-reconfigure mysql-community-server

If you don't want to use mysql-server anymore you can run:

apt-get remove mysql-community-server mysql-server

To remove entirely those packages from your system. That should solve the problem.

0
0

It seems, that starting the server (again) from the postinst script is failing. This can have different reasons, often the service is still running (e.g. because actually the stop action before failed), but it is possible that mysql cannot start because of some problem.

Try running /etc/init.d/mysql stop;/etc/init.d/mysql start; and look if there are any errors. If mysql doesn't stop correctly, you can try to kill it with killall.

If you got it fixed, run dpkg --configure -a to configure all packages which were held back when the postinst script failed.

Another hack is finding the postinst script in /var/lib/dpkg and putting an exit 0 after the #!/bin/sh line, then running dpkg --configure -a and then removing the line. Be warned, that any (possibly important) parts of the postinst script are not run.

0

TO REMOVE bugged MYSQL and INSTALL MYSQL -> Workbench working well:

Total time searching for this solution = 1h 40min in all forums (also from mysql original website && from chinese forums)


1) First of all

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

sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor

sudo apt-get install mysql-server mysql-common

sudo mysql -u root -p

mysql> quit

2) Follow steps from this tutorial How To Install MySQL 8.0 On Ubuntu 18.04



3) Follow steps from this tutorial A Quick Guide to Using the MySQL APT Repository

- INSTEAD OF "libmysqlclient18" USE "libmysqlclient21"

- FINISH ON COMMAND "apt-get source -b mysql-server"

    - CONTINUE STEP 4


4) Ubuntu software (software platform) Ubuntu 18.04

- Search "mysql" or "workbench" and find "MySQL Workbench"
- install


5) Removing sudo... = AVOIDING ERRORS on loading databases

5.1. sudo mysql -u root -p

5.2. mysql> use mysql;

5.3. mysql> select user, host, plugin from mysql.user;

5.4. mysql> create user 'gabriel'@'localhost' identified by 'gabriel';

5.5. mysql> grant all privileges on *.* to 'gabriel'@'localhost';   

// **all privileges on *asterisk* dot *asterisk** (idk why but it doesn't allow * asterisk) 

5.6. mysql> update user set plugin="auth_socket" where User='gabriel';

5.7. mysql> flush privileges;

5.8. mysql> exit

5.9. sudo service mysql restart

5.10. mysql -u gabriel -p

5.11. mysql> show databases;

5.12. mysql> quit

Start "MySQL Workbench" and when it asks for password, click save in the "keychain" and click enter without entering password.

Done. :)


Extra: (for adding new databases):

     (from new db)

On the folder "employees_db" (or whatever it might be), execute the command:

mysql -u root -p -t < employees.sql
0

On Ubuntu 16.04, what worked for me was enabling mysql.service prior to sudo apt-get update and sudo apt-get upgrade. This is because I normally have mysql.service disabled.

I.e. I did the following:

sudo systemctl enable mysql.service
sudo apt-get update
sudo apt-get upgrade

Taking the above steps (in the order shown) allowed my system to update and upgrade successfully.

If you don't want to keep the mysql service enabled following reboot, then also do

sudo systemctl disable mysql.service
-1

I had this issue with a server with 512 MB RAM. There was no such issue after I upgraded to 1 GB RAM.

2
  • 2
    There is no indication that the error that the user gets is due to too little RAM.
    – Kusalananda
    Dec 30, 2019 at 7:31
  • Yes, there is no indication it was due to memory issues. I had tried the other solutions here, but the error persists. Finally, I upgraded from 512 MB to 1 GB RAM, then the installation succeeded.
    – Zhiyong
    Dec 31, 2019 at 5:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .