unable to uninstall mysql broken mysql / install new mysql - mysql

I have made some shitty things to MySQL and I facing this.
I am trying to re-install MySQL. directly deleted the MySQL folder using sudo rights and tried to re-install.
the fix will be greatly appreciated
command I am running
sudo apt-get install mysql-server
following is the output I am receiving
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.26-0ubuntu0.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 37 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.26-0ubuntu0.18.04.1) ...
/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)

https://askubuntu.com/a/1134184/653440
do: sudo apt edit-sources and look for anything containing mariadb like: deb [arch=amd64,arm64,ppc64el] http://ftp.nluug.nl/db/mariadb/repo/10.3/ubuntu bionic main
comment it out by putting a # in front of it. then run
sudo apt update
sudo apt purge mysql-common
sudo apt install mysql-common
after that you can installed mysql-server properly via sudo apt install mysql-server
Helped me fix the issue.

Related

Unable to uninstall mysql

Hi I've been having some problems lately with starting mysql in Ubuntu-22.04.
When i try sudo service mysql start an error pops up:
Failed to start mysql.service: Unit mysql.service failed to load properly, please adjust/correct and reload service manager: File exists
See system logs and 'systemctl status mysql.service' for details.
I've also tried some "fixes" from stackoverflow and other forums but none of them seemed to work mainly because of the autoremove part.
root#server-HP-Z420-Workstation:~# apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-8.0 (8.0.30-0ubuntu0.22.04.1) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned
error exit status 2
Errors were encountered while processing:
mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)
Any ideas?
Try uninstalling and installing the server like this:
sudo apt-get clean
sudo apt-get purge mysql*
sudo apt-get update
sudo apt-get install -f
sudo apt-get install mysql-server-8.0

Can't install mysql-server package

I am trying to install the mysql-server package on debian and I am getting an error:
t#mintserver:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
mysql-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/2.942 kB of archives.
After this operation, 111 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 372098 files and directories currently installed.)
Preparing to unpack .../mysql-server_5.7.29-0ubuntu0.18.04.1_all.deb ...
Unpacking mysql-server (5.7.29-0ubuntu0.18.04.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 installed.
I read many other replies that told me to purge the packages, correct dependencies, but nothing works.
t#mintserver:~$ sudo apt install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 0 B/2.933 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not installed.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Please, run sudo dpkg --audit or sudo dpkg -C, it's the same. It probably will suggest to you what to do.
Edit: According to your comment,
Setting up mysql-server-5.7 (5.7.29-0ubuntu0.18.04.1) ... update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist dpkg: error processing package mysql-server-5.7 (--configure): installed mysql-server-5.7 package post-installation script subprocess returned error exit status 2 Errors were encountered while processing: mysql-server-5.7
the update-alternatives program failed to find this mysql.cnf file.
Could you try creating that file?
Please, do:
sudo nano /etc/mysql/mysql.cnf
filling with this content:
[mysql]
Then, try again dpkg --configure <package>
Or, this will probably do the job:
sudo apt-get remove --purge mysql-\*
sudo apt-get install mysql-server mysql-client
If interested, you could also read A Quick Guide to Using the MySQL APT Repository. They provide different installation approaches for different scenarios.

Can not install mysql ubuntu after removing maria db

I was working on mysql database, and unfortunately I installed mariadb and when I want to go back to mysql I have error , I removed mariadb and trying to install mysql with this command
sudo apt-get install mysql-server
but I have this error
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.22-0ubuntu0.16.04.1).
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.22-0ubuntu0.16.04.1) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't
exist
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 2
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)
and I can not re install mysql , what can I do , I looked for solution but don't have result
Try doing a purge, then re-install.
sudo apt-get remove --purge mysql-\*
sudo apt-get install mysql-server mysql-client

Ubuntu 16.04 can't rebuild mySQL

I am trying to do a clean reinstall of mySQL on my local machine for various reasons. I have followed sever posts here and on stack. particularly followed this post in detail, however every time I go through the steps I end at the same result.
Setting up mysql-client (5.7.20-0ubuntu0.16.04.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
No apport report written because the error message indicates its a followup error from a previous failure.
Setting up mysql-client (5.7.20-0ubuntu0.16.04.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
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)
I am absolutely stumped at this point...
As discussed earlier in the discussion in the post, I think you are safe to reinstall it. We should remove all traces of previous installation of mysql and then reinstall it.
sudo apt-get remove --purge mysql*
If these were installed as part of the package dependencies for mysql,
sudo apt-get autoremove
sudo apt-get autoclean
Then the important bit, this error could be caused because your distribution is not upgraded recently, or at least conflicts are not resolved properly. I would just upgrade Ubuntu.
sudo apt-get dist-upgrade
Now after this is done, you can try to install mysql as normal again. Hope this will work, please give a report. If it doesnt work we'll try another fix.
Here's a link to digital oceans installation for mysql. Though you could use MariaDB.
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04

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