1

Trying to install mysql, I always get the following error:

Errors were encountered while processing: /var/cache/apt/archives/mysql-server-5.7_5.7.21-0ubuntu0.17.10.1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

See in full below:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-server-5.7
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 0 B/3,184 kB of archives.
After this operation, 48.3 MB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 283762 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.21-0ubuntu0.17.10.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.21-0ubuntu0.17.10.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.7_5.7.21-0ubuntu0.17.10.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried this solution as well as almost every solution available on stackoverflow but it doesn't solve my problem Even mysql server is not entirely removed by sudo apt-get remove --purge mysql-server. I've to remove it by using synaptic manager

What worked for me: Disabling all the third party repositories and the following the linked question instruction again

  • If you have really tried "every solution available on stackoverflow", then please edit your question to tell us exactly what you tried, and exactly what each result was. – user535733 Mar 6 '18 at 0:01
0

The mysql service is allready running on your system. try

sudo service mysql stop

or read this: How do I start/stop mysql server?

after that, you should check which version of mysql is installed and see if you actually need a different version.

  • Failed to stop mysql.service: Unit mysql.service not loaded. – Prabhat Sharma Mar 5 '18 at 20:59
  • Try to clean out the apt-cache too, you have 6 packages not upgraded, and 2 suggested packages. try apt-get clean and apt-get autoremove – Glenn van Acker Mar 5 '18 at 21:05
  • this maybe stupid, but have you tried simply rebooting your system? – Glenn van Acker Mar 5 '18 at 21:07
  • Nopes it didn't worked. I thing the main problem here is " Stopping mysql (via systemctl): mysql.serviceFailed to stop mysql.service: Unit mysql.service not loaded. failed!" – Prabhat Sharma Mar 5 '18 at 21:10
  • Nopes I've tried almost everything that is available on net but not rebooting – Prabhat Sharma Mar 5 '18 at 21:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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