Need to correct mistake with installing MySQL while it was already installed

Discussion in 'Server Operation' started by masteripper, Jul 6, 2020.

Tags:
  1. masteripper

    masteripper New Member

    Hello
    I have made an installation mistake while trying to install the complete prequisities for Postfix

    sudo apt-get install postfix postfix-mysql dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql mysql-server dovecot-sieve dovecot-managesieved​
    but the server already had mySQL 8 installed...
    So from now on whenver i install something i also get this :
    Setting up mysql-server-5.7 (5.7.30-0ubuntu0.16.04.1) ...
    Renaming removed key_buffer and myisam-recover options (if present)
    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 preset: enabled)
    Active: activating (auto-restart) (Result: exit-code) since Mon 2020-07-06 06:19:07 UTC; 5ms ago
    Process: 9757 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

    Jul 06 06:19:07 ip-172-26-11-59 systemd[1]: mysql.service: Control process e...1
    Jul 06 06:19:07 ip-172-26-11-59 systemd[1]: Failed to start MySQL Community ....
    Jul 06 06:19:07 ip-172-26-11-59 systemd[1]: mysql.service: Unit entered fail....
    Jul 06 06:19:07 ip-172-26-11-59 systemd[1]: mysql.service: Failed with resul....
    Hint: Some lines were ellipsized, use -l to show in full.
    dpkg: error processing package mysql-server-5.7 (--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.7; however:
    Package mysql-server-5.7 is not configured yet.

    dpkg: error processing package mysql-server (--configure):
    dependency problems - leaving unconfigured
    Setting up rar (2:5.3.b2-1) ...
    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.7
    mysql-server
    E: Sub-process /usr/bin/dpkg returned an error code (1)


    Any clue on how to clear this ?
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Remove all components of both mysql versions. Then install the mysql you want.
    You can use
    Code:
    dpkg --list | grep -i mysql
    
    to see what mysql packages are installed.
     
    masteripper likes this.
  3. masteripper

    masteripper New Member

    This is what i get from your command :
    Code:
    ii  dovecot-mysql                    1:2.2.22-1ubuntu2.12                       amd64        secure POP3/IMAP server - MySQL support
    ii  libmysqlclient20:amd64           5.7.30-0ubuntu0.16.04.1                    amd64        MySQL database client library
    ii  mysql-client-5.7                 5.7.30-0ubuntu0.16.04.1                    amd64        MySQL database client binaries
    ii  mysql-client-core-5.7            5.7.30-0ubuntu0.16.04.1                    amd64        MySQL database core client binaries
    ii  mysql-common                     5.7.30-0ubuntu0.16.04.1                    all          MySQL database common files, e.g. /etc/mysql/my.cnf
    iU  mysql-server                     5.7.30-0ubuntu0.16.04.1                    all          MySQL database server (metapackage depending on the latest version)
    iF  mysql-server-5.7                 5.7.30-0ubuntu0.16.04.1                    amd64        MySQL database server binaries and system database setup
    ii  mysql-server-core-5.7            5.7.30-0ubuntu0.16.04.1                    amd64        MySQL database server binaries
    ii  postfix-mysql                    3.1.0-3ubuntu0.3                           amd64        MySQL map support for Postfix
    I am pretty sure that there is another instance already running....
    I don't want to delete anything...just stop the message.
    Well i was right

    Code:
    $ mysql -V
    /opt/bitnami/mysql/bin/mysql.bin  Ver 8.0.18 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
    
    There is a mysql installation running....i just need to "remove" the above packages
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Is that other instance of mysql installed by some other means and not with apt install? If that is the case, you need to see the installation package of that method, it may have uninstall command or script somewhere.
    You do not bother to mention what OS you are running. Maybe it is Ubuntu? You could try seeing what processes or services are running:
    Code:
    ps -ef | egrep -i "(maria|mysql)"
    systemctl | egrep -i "(maria|mysql)"
    
     
    masteripper likes this.
  5. masteripper

    masteripper New Member

    this is the output from 1st command
    Code:
    ps -ef | egrep -i "(maria|mysql)"
    root      4640     1  0 Jul05 ?        00:00:00 /bin/sh /opt/bitnami/mysql/bin/mysqld_safe --defaults-file=/opt/bitnami/mysql/my.cnf --mysqld=mysqld.bin --socket=/opt/bitnami/mysql/tmp/mysql.sock --datadir=/opt/bitnami/mysql/data --log-error=/opt/bitnami/mysql/data/mysqld.log --pid-file=/opt/bitnami/mysql/data/mysqld.pid --lower-case-table-names=1
    mysql     4959  4640  0 Jul05 ?        00:02:35 /opt/bitnami/mysql/bin/mysqld.bin --defaults-file=/opt/bitnami/mysql/my.cnf --basedir=/opt/bitnami/mysql --datadir=/opt/bitnami/mysql/data --plugin-dir=/opt/bitnami/mysql/lib/plugin --user=mysql --lower-case-table-names=1 --log-error=/opt/bitnami/mysql/data/mysqld.log --pid-file=/opt/bitnami/mysql/data/mysqld.pid --socket=/opt/bitnami/mysql/tmp/mysq .sock --port=3306
    bitnami  10943  9329  0 09:25 pts/0    00:00:00 grep -E --color=auto -i (maria|mysql)
    and the 2nd
    Code:
    systemctl | egrep -i "(maria|mysql)"                                                                                                                              
    ● mysql.service                                    loaded failed failed  
    MySQ                                                                                                                                
    Community Server
    this is an AWS Lightsail so i don't have "complete" control
    As you can see on my previous post there is a perfectly running mysql 8.0.18 inside the "bitnami" package
     
  6. masteripper

    masteripper New Member

    As for the OS :
    Code:
    NAME="Ubuntu"
    VERSION="16.04.6 LTS (Xenial Xerus)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 16.04.6 LTS"
    VERSION_ID="16.04"
    HOME_URL="http://www.ubuntu.com/"
    SUPPORT_URL="http://help.ubuntu.com/"
    BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
    VERSION_CODENAME=xenial
    UBUNTU_CODENAME=xenial
    
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Indeed, there is mysql running. You or someone else seems to have installed in
    /opt/bitnami/mysql/bin some version of mysql.
    I do not know what AWS Lightsail is. If you can not uninstall stuff, then go with the already installed mysql. Remove the mysql packages you tried to install:
    Code:
    apt remove mysql-client-5.7 mysql-client-core-5.7 mysql-common   mysql-server mysql-server-5.7 mysql-server-core-5.7
    apt autoremove
    
     
    masteripper likes this.
  8. masteripper

    masteripper New Member

    The critical question...do you think that removing the packages will affect the running mysql (8)
    Sorry if its too obvious but trying to keep the original mySQL running...
    The running MySQL comes pre installed with LightSail
     
  9. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Try it and see. I would assume it does not affect the other mysql. You could verify where the running mysql has its configuration files, if they are in /etc/mysql there may be problems if the to be removed mysql alters them. Make a backup of /etc/mysql directory tree just in case, so you can put them back if need be.
     
  10. masteripper

    masteripper New Member

    This seems like a good idea....i will try it and keep you posted...
     
  11. masteripper

    masteripper New Member

    I got a complete image backup before doing everything and removed everything about mysql
    Seems good ...no more complaing when i install/remove packages
    From the 1st command you gave me i see this
    Code:
    dpkg --list | grep -i mysql
    rc  mysql-common                     5.7.30-0ubuntu0.16.04.1                    all          MySQL database common files, e.g. /etc/mysql/my.cnf
    rc  mysql-server-5.7                 5.7.30-0ubuntu0.16.04.1                    amd64        MySQL database server binaries and system database setup
    
    Should i remove something here ?...is it just ok to leave them ?
     
  12. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    The rc at beginning of line means they are removed but configuration files still exist. If you now install with apt a mysql-server-5.7 it tries to use the existing configuration.
    If you want to get rid of the configuration files to start configuring from a clean slate, use
    Code:
    apt purge mysql-common mysql-server-5.7 
    By the way, things like these tend to be documented, and it may be faster to read the docs than to wait for answers in forums. Output format of dpkg --list is explained in man dpkg-query, and purge is explained in man apt and man apt-get.
     
    masteripper likes this.
  13. masteripper

    masteripper New Member

    I am afraid i am not a Linux guy and this came as an emergency...if you want Windows on the other hand ...lets say i am in a pretty good level... :)
    I did tried to remove them but a screen came about deleting files so i will take some time to investigate it
    Thanks a lot for your time...you have being a true helping hand.
     
    Last edited: Jul 7, 2020

Share This Page