Problems installing MySQL on Ubuntu 20.04 - mysql

I am trying to install MySQL 8.0 in Ubuntu 20.04 with sudo apt install mysql-server, but this error keeps showing up after reinstalling and after using sudo dpkg --configure -a :
Setting up mysql-server-8.0 (8.0.25-0ubuntu0.20.04.1) ...
/var/lib/dpkg/info/mysql-server-8.0.postinst: line 191: /usr/share/mysql-common/
configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned
error exit status 127
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
I completely uninstalled MySQL and reinstalled it multiple times with sudo apt remove --purge --autoremove mysql-server, but the error persists.

I got the same problem and just found nice article
to solve it.
Indeed deleting files directly from your MySQL folder is really not recommended. You can take a look at this guide here on how to delete old MySQL binary files here.
Regarding your current issue. In order to completely get rid of your MySQL installation you could run the following:
Make sure MySQL is not running:
sudo systemctl stop mysql
Then purge all the MySQL packages:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
Then delete all the MySQL files:
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
Finally clean all packages that are not needed:
sudo apt autoremove
sudo apt autoclean
Hope that this helps!

Stop the Mysql if it is running
sudo systemctl stop mysql.service
sudo kill $(pgrep mysql)
Then purge everything , this will also remove Mysql-workbench
sudo apt-get remove --purge mysql-\*
Then reinstall mysql-server and mysql-client
sudo apt-get install mysql-server mysql-client

Related

mysql-server-5.7 is not configured yet

I installed Mysql5.7 long time ago, afterwards I uninstalled it and installed MariaDB disabling apparmor (mysql) profile.
Now I uninstalled MariaDB and I'm trying to install mysql5.7 and I got this error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.28-0ubuntu0.18.04.4).
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-server-5.7 (5.7.28-0ubuntu0.18.04.4) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 191: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 127
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
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)
I get this error when I use sudo dpkg --configre -a too.
I install the package using sudo apt install mysql-server.
I tried to follow some guide online, I removed /var/lib/dpkg/info/mysql-server-5.7.postinst purged mariadb, mysql and tried a lot of things.
Ok, I solved in this way:
I used Software & Updates application to remove mariadb sources
executed the followings steps (ref https://askubuntu.com/a/934576):
sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server
sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install
sudo apt install mysql-server
This fixed it for me (MySQL 8.0 - Ubuntu 20.04)
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
But the package "mysql-client-core-8.0" don't uninstall, so...
sudo apt --fix-broken install
sudo apt-get --reinstall install mysql-client-core-8.0
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
sudo apt update
sudo apt install mysql-server
No more errors!
Try this:
sudo dpkg -P mysql-server mysql-server-5.1
sudo apt-get autoremove
sudo apt-get clean
dpkg -l | grep -i mysql
sudo rm -rvf /var/lib/mysql
sudo apt-get install mysql-server
The step dpkg -l | grep -i mysql will show you all mysql modules, which are installed. It should be empty before the next steps.
This error could also happen if the port (3306) is being used by another app. In my case, I had a docker container running mysql which was using the 3306 port. Hence my local mysql installation failed to configure.
$ sudo netstat -nltp | grep LISTEN | grep 3306
$ sudo netstat -nltp | grep LISTEN | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 1017033/docker-prox
sudo apt purge --auto-remove mysql*
sudo rm -r /etc/mysql
sudo rm -r /var/lib/mysql*
sudo apt install mysql-client-8.0 mysql-server-8.0 --fix-broken -y

dpkg: error processing package mysql-server (dependency problems)?

When I try to install mysql-server, an error comes like:
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
What does it mean. Any ideas?
dpkg returning an error code 1 doesn't mean anything specific but it usually has to do with dependency issues. In your case, you tried to install two versions/instances of the same package i.e. mysql-server and mysql-server-5.7. So do the following to remove any redundant dependency issues and install a functioning mysql package
sudo apt-get clean
sudo apt-get purge mysql*
sudo apt-get update
sudo apt-get install -f
sudo apt-get install mysql-server-5.7
sudo apt-get dist-upgrade
this should fix the problem at hand. But in the future, have care about the package names you add after sudo apt-get install since the wrong list of package names - for example redundant entries in the list - results in failure to install either of the packages or worse - you might even find yourself wading through the hellish depths of #DEPENDENCY-HELL
All of the answers I've been able to find for this question have been of the form "purge your Mysql install and re-install it." But in my case, I already have a working/active Mysql install. For me, the reason why dpkg --configure -a fails is because Mysql is already installed. Why dpkg thinks that the postinstall script needs to be run for my already-installed-and-upgraded Mysql I may never know, but it does.
After considerable time scouring for answers, I found a solution that should work if there are others who already have a working Mysql 5.7 and just want to get past this bogus postinstall script. You can edit the postinstall script directly as (on Ubuntu):
sudo vi /var/lib/dpkg/info/mysql-server-5.7.postinst
And then, on the second line, just add exit 0 and then run dpkg again and you should get something like:
$ sudo dpkg --configure -a
Setting up mysql-server-5.7 (5.7.28-0ubuntu0.18.04.4) ...
You definitely would not want to follow these instructions if your Mysql installation had not previously completed (there's a reason that the postinstall script insists on running). But for those who might end up with dpkg in a wonky state, as I have, the above can save you a lot of time purging and reinstalling an already-working version of Mysql.
This should help
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
And now reinstall mysql
sudo apt-get install mysql-server
If you're on a VPS or similar, your error may be due to lack of RAM.
Running apt-upgrade seems to require some RAM, so it may force-close mysql, hence the problem to recover from the error.
Try:
1) Stop mysql manually before any apt-upgrade
sudo /etc/init.d/mysql stop
2) Fix:
sudo dpkg --configure mysql-server-X.X
(if version not known, use just mysql-server to find out (will not fix error)
3) Check:
sudo apt-get upgrade
Start mysql manually if it wasn't started by apt.
I had a similar issue. This is how I fixed mine.
Restart MySQL service sudo service mysql restart
Then fix broken installations sudo apt install -f
My answer from askubuntu.
New Answer
kill the musql deamon and purging helps
sudo pkill mysqld # kill
sudo apt-get purge mysql-server-5.7 # Or whatever you are trying to purge.
Thanks, #endrias for the suggestion.
Old Answer
None of the apt methods worked for me, try this:
Find locking process
$ ps -eaf
root 7316 1 0 00:19 ? 00:00:00 /usr/bin/dpkg --status-fd 35 --configure --pending
root 7808 7316 0 00:19 ? 00:00:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-se
root 7817 7808 0 00:19 ? 00:00:00 /bin/bash /var/lib/dpkg/info/mysql-server-5.7.postinst configure
mysql 7973 7817 0 00:20 ? 00:00:00 mysqld --user=mysql --init-file=/var/lib/mysql-files/tmp.iNyY06ty0K --so
Kill it
do sudo kill -9 7973, basically the mysql one.
Now purge
sudo apt-get purge mysql-server-5.7 # Or whatever you are trying to purge.
i face same error due to problem in my upgrade from ubuntu 18.04 to ubuntu 20.04 , what i did is get mariadb instead also make sure when you do pruge mysql that if asked you to remove dbs in the dir
tell it not to delete the dbs so you will have your old databases with no data loss
what i did was this cmds
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
sudo apt-get install mariadb-server
I tried almost every possible way but nothing was working for me. Then I found the problem that I was facing was due to less available ram. You can check your current ram status by free -h (in my case available was less than 1 GB). To clear ram restart your device. Then type following commands
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
then again install mysql-server by
sudo apt-get install mysql-server
try this solution using aptitude this will replace all the file corrupted.
This is work on my 18.04
cr. https://www.digitalocean.com/community/questions/mysql-installation-error-dpkg-error-processing-package-mysql-server-5-5-configure?answer=61604
In my case I had to run:
systemctl stop mysql.service
to stop MySQL before being able to install mysql without errors using:
sudo apt-get install mysql-server
To solve the dependency issue, try:
sudo apt-get purge
sudo apt-get clean
sudo apt-get check
And reinstall the package again by: sudo apt-get install mysql-server.
Source: Thread: Dpkg: Dependency problems - leaving unconfigured.
Other commands to try:
sudo apt-get install -f
sudo apt-get autoremove
sudo dpkg --configure -a
Related: How can I Resolve dpkg dependency? at Ask Ubuntu.
The problem can be much simpler (in my case) I had a missconfigured value in my configuration file [my.cnf] which lead to the error.
After cleaning up my.cnf mysql-server was restarted successfully
If you are working on Debian 10, you need to first install GNUPG:
sudo apt-get install gnupg
That's all; now you can try dpkg again.
Also pay attention to the terminal you are using, if it is ZSH many uninstall commands will not work like: sudo apt-get purge mysql* and the reinstallation process will fail, to fix this it is simple type in your terminal the word bash so that the terminal used is Bash, run the sudo apt-get purge mysql* command again and also the following commands below to confirm that you removed everything.
sudo apt-get remove mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
Finally, run mysql --version to make sure there is no version on your machine and you can try installing again.
I came across the yes Unix binary, which is incredibly stupid: it just endlessly types y (try it, you can just run yes in your terminal)
so the following just works (I used this in a dockerfile)
yes | apt-get install mysql-community-server
I had another mysql process running in background.
(ckeck if your lampp mysql server is on, Then turn it off.)
then try
sudo apt dist-upgrade
if lammp mysql is not working then,
check this command,
ps -eaf
and then look for mysql process and kill it by it's port number
sudo kill -9
I was in the same situation. After completely removing MySQL, I reinstalled it, killed the PID using port 3306, and reinstalled MySQL again. It's working now.

Completely Remove MySQL Ubuntu 14.04 LTS

I somehow have messed up my MySQL on my Ubuntu server and cannot fix it. I have tried every single combination of apt-get remove --purge mysql-server, apt-get autoremove, apt-get purge, Googled for hours and nothing.
I have literally given up. Every time I try to reinstall I get error. I've had enough. I want to remove every single file associated with MySQL on my server.
I get this error every time I try to reinstall which seems to be common but not one "fix" has worked for me. I need to clean my system of everything MySQL.
Unable to set password for the MySQL "root" user
An error occurred while setting the 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.
Please can someone give me a set of command to purge this ungodly database from my system before I do a fresh install of the server.
Setting up mysql-server-5.5 (5.5.38-0ubuntu0.14.04.1) ...
140811 10:56:44 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--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.5; however:
Package mysql-server-5.5 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.
Processing triggers for libc-bin (2.19-0ubuntu6.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
I have literally tried everything. Every single mysql file is removed and it still will not install properly.
To completly remove Mysql from Ubuntu :
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
after this, if you are having issues with re installing, Try to remove Mysql files in :
sudo rm -rf /var/lib/mysql
I experienced a similar issue on Ubuntu 14.04 LTS after a MySQL update.
I started getting error: "Fatal error: Can't open and lock privilege tables: Incorrect file format 'user'" in /var/log/mysql/error.log
MySQL could not start.
I resolved it by removing the following directory: /var/lib/mysql/mysql
sudo rm -rf /var/lib/mysql/mysql
This leaves your other DB related files in place, only removing the mysql related files.
After running these:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
Then reinstalling mysql:
sudo apt-get install mysql-server
It worked perfectly.
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.
The following works:
sudo apt-get --purge remove mysql-client mysql-server mysql-common
sudo apt-get autoremove
Use apt to uninstall and remove all MySQL packages:
$ sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
$ sudo apt-get autoremove -y
$ sudo apt-get autoclean
Remove the MySQL folder:
$ rm -rf /etc/mysql
Delete all MySQL files on your server:
$ sudo find / -iname 'mysql*' -exec rm -rf {} \;
Your system should no longer contain default MySQL related files.
sudo apt-get remove --purge mysql*
Remove the MySQL packages fully from the target system.
sudo apt-get purge mysql*
Remove all mysql related configuration files.
sudo apt-get autoremove
Clean up unused dependencies using autoremove command.
sudo apt-get autoclean
To clear all local repository in the target system.
sudo apt-get remove dbconfig-mysql
If you also want to delete your local/config files for dbconfig-mysql then this will work.
This is what saved me. Apparently the depackager tries to put things in the wrong tmp folder.
https://askubuntu.com/a/248860
Remove /etc/my.cnf file and retry the installation, it worked for me for exactly same problem. :-)
remove mysql :
sudo apt -y purge mysql*
sudo apt -y autoremove
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql*
Restart instance :
sudo shutdown -r now
I just had this same issue. It turns out for me, mysql was already installed and working. I just didn't know how to check.
$ ps aux | grep mysql
This will show you if mysql is already running. If it is it should return something like this:
mysql 24294 0.1 1.3 550012 52784 ? Ssl 15:16 0:06 /usr/sbin/mysqld
gwang 27451 0.0 0.0 15940 924 pts/3 S+ 16:34 0:00 grep --color=auto mysql

MySQL Fails to Reinstall (Ubuntu 12.10 Server)

I'm running a Wordpress installation on an Ubuntu 12.10 server. The site was running fantastically until we had sporadic MySQL issues, where the site would "whitescreen" for a few hours, then return to normal.
Someone who should not have been toying around with the server removed MySQL to attempt a reinstall, and now mySQL refuses to reinstall. I get the following errors when running sudo apt-get install -f mysql-server from root.
Setting up mysql-server-5.5 (5.5.35-0ubuntu0.12.10.2) ...
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
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server-5.5
mysql-server
In addition, I couldn't connect to MySQL through the socket before this all happened.
Things I've tried, as recommended here/on other websites:
Restarting mysqld Deleting and (attempting) reinstallation of mysql-server
deleting all files shown when running dpkg -S etc/mysql
apt-get purge mysql-server mysql-client mysql-common mysql-client-5.5 mysql-server-5.5
apt-get auto cleans
apt-get with the -f flag
Numerous server reboots and restarts
Tears
Have you tried entering this through terminal/PuTTy?
apt-get install mysql-server mysql-client

MySQL Won't Install on Ubuntu 11.04

It was working fine before and I was configuring the email server when I restarted the mysql (via /etc/init.d/mysql restart). I'm pretty sure that I did not touch anything in there but I can remember doing a failed apt-get update prior to that.
Now my problem starts when all of a sudden it stops and won't even start. I searched on google and even went far to purging everything and doing a new install. But still it won't let me install mysql properly.
I've tried (after doing a remove --purge):
sudo apt-get install mysql-server-5.5 mysql-client-5.5
and it prompts me for a root passsword, but returns me the following error:
Unable to set password for the MySQL "root" user
An error occurred while setting the 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.
and I have the following logs too:
Selecting previously deselected package mysql-server-5.5.
(Reading database ... 117879 files and directories currently installed.)
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.32-0ubuntu0.12.04.1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up mysql-server-5.5 (5.5.32-0ubuntu0.12.04.1) ...
130830 14:13:26 [ERROR] Can't find messagefile '/usr/share/mysql/errmsg.sys'
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)
any help? Thanks in advance.
this question was having the same issue it solved by uninstalling but before that he tried to set the password that is the question and then he tried to solve it in chat maybe when you try to set a password it will be solved , just try
Update: Type the following commands in your terminal in order to make a complete remove for mysql.
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
Also you need to remove the /var/lib/mysql folder if exist by typing the following command
sudo rm -rf /var/lib/mysql
Then follow the official ubuntu documentation to install. and don't forget to set your mysql password during installation.
Also see this question its similar to the error you have got during the installation process.
I experienced this problem.
maybe aptitude have some config for package.
I think this problem of interference
Although, this method is purge command .
try running.
check installed mysql package
dpkg --get-selections|grep mysql
remove
apt-get remove --purge [installed package]
apt-get autoremove
apt-get autoclean
aptitude purge [installed package]
aptitude clean
aptitude update
aptitude -f install
aptitude full-upgrade
install
apt-get install mysql-server