Issues on reinstalling MySQL 5.7 server on Ubuntu 16.04 - mysql

My server is running on Ubuntu 16.04
I hade some issue with my MySQL configuration, so I've decided to clean up and reinstall the MySQL server.
After this command:
sudo apt-get install mysql-server
This is what i got at the end of the process:
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
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.
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-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-0ubuntu5) ...
Processing triggers for systemd (229-4ubuntu13) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
I try to start the MySQL and running systemctl status mysql.service gave this:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Tue 2016-12-20 17:33:32 BDT; 14s ago
Process: 22634 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 22631 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 22634 (code=exited, status=1/FAILURE); : 22635 (mysql-systemd-s)
Tasks: 2
Memory: 1.5M
CPU: 337ms
CGroup: /system.slice/mysql.service
└─control
├─22635 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─22669 sleep 1
When I try to connect the database using mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I meet same problem today, and finally I found out this is because in my.cnf there is something like that:
log_slow_queries = /var/log/mysql/mysql-slow.log
But in Mysql 5.7, log_slow_queries is deprecated, change to
slow_query_log_file = /var/log/mysql/mysql-slow.log
solved my problem.

Make sure there is no other mysql process running. I had an dead mysql process running, which caused in a conflict / upgrade error.
ps -aux | grep 3306 If there are any "dead" mysql processes, kill them like this `sudo kill -15 {pid here}.
Then run the upgrade again.
Cheers
Unkn0wn0x

You may want to try installing from source so you can try to pinpoint what is exactly causing the problem.
First remove all partially installed mysql packages using:
$ sudo apt-get remove --purge mysql\*
Then follow this guide:
https://dev.mysql.com/doc/refman/5.7/en/source-installation.html
Alternatively, you could install MariaDB which is a drop-in replacement for mysql:
$ sudo apt-get install mariadb-server
I have started using MariaDB on Ubuntu instead of MySQL and it works well for me.

Related

Ubuntu / DigitalOcean - Unable to Install MySql

I’m following the LAMP tutorial on DigitalOcean (https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04), but I don’t seem to be able to install MySQL on Ubuntu 22.04 . I tried deleting my droplet, making a new one, and installing MySQL before anything else, but I still get the following after running “sudo apt install mysql-server”:
mysqld will log errors to /var/log/mysql/error.log 2022-07-11T19:20:59.707275Z 0 [ERROR] [MY-011065] [Server] Unable to determine if daemon is running: Invalid argument (rc=0). 2022-07-11T19:20:59.708151Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log. Warning: Unable to start the server. Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service. Job for mysql.service failed. See “systemctl status mysql.service” and “journalctl -xeu mysql.service” 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: oom-kill) since Mon 2022-07-11 19:21:04 UTC; 36ms ago Process: 2778 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Process: 2786 ExecStart=/usr/sbin/mysqld (code=killed, signal=KILL) Main PID: 2786 (code=killed, signal=KILL) Status: “Server startup in progress” CPU: 1.229s dpkg: error processing package mysql-server-8.0 (–configure): installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1 Setting up libcgi-pm-perl (4.54-1) … Setting up libhtml-template-perl (2.97-1.1) … 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 Setting up libcgi-fast-perl (1:2.15-1) … No apport report written because the error message indicates its a followup error from a previous failure. Processing triggers for man-db (2.10.2-1) … Processing triggers for libc-bin (2.35-0ubuntu3) … Errors were encountered while processing: mysql-server-8.0 mysql-server needrestart is being skipped since dpkg has failed E: Sub-process /usr/bin/dpkg returned an error code (1)
Thanks in advance for any advice
It was failing due to lack of memory, I upgraded from 512MB to 1GB, and it now works

Broken mysqld package preventing any other installation in ubuntu

I am having this issue for quite a long period of time, it started when I wanted to change password for mysql which I forgot. I have followed a lot of documents to purge mysql from my system completely so that I can have a new password for a freshly installed mysql. But every time I install it I face the same problem and it asks me the same old password.
Currently I have purged mysql from my system but even though whenever I try to install anything, let's say openssh, I get the below logs after downloading the package.
sudo apt-get install openssh-server
.
.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 9069
Job for mysql.service failed because a timeout was exceeded.
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)
Drop-In: /etc/systemd/system/mysql.service.d
└─override.conf
Active: activating (auto-restart) (Result: timeout) since Sat 2021-07-03 00:35:37 IST; 5ms ago
Process: 9257 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 9278 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid --skip-grant-tables --skip-networking (code=exited, status=0/SUCCESS)
Main PID: 9278 (code=exited, status=0/SUCCESS)
Status: "Server shutdown complete"
Error: 2 (No such file or directory)
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: Stopped MySQL Community Server.
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: Starting MySQL Community Server...
Jul 03 00:35:41 gp-HP-Pavilion-Notebook systemd[1]: mysql.service: Got notification message from PID 10009, but reception only permitted for main PID 10007
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
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
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is there any way to prevent this from happening every time when I install anything ?
It would be great if anyone could help in resolving this issue, because it is also blocking the proper installation of various other package.
The log says: See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service will show the status of the mysql.service.
systemctl stop mysql.service will stop the mysql.service.
systemctl start mysql.service will start the mysql.service.
systemctl enable mysql.service will start the mysql.service at boot.
systemctl disable mysql.service will stop the starting of the mysql.service at boot. (I think you need this one)
more info: man systemctl, and systemctl --help

MySQL install is broken, cant install

My MySQL community install was broken, so i reinstalled it. Now, it won't install at all. Help!
This is the output when running sudo apt-get install mysql-server
Setting up mysql-client-5.7 (5.7.29-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.29-0ubuntu0.18.04.1) ...
Installing new version of config file /etc/apparmor.d/usr.sbin.mysqld ...
Installing new version of config file /etc/logrotate.d/mysql-server ...
Installing new version of config file /etc/mysql/debian-start ...
Renaming removed key_buffer and myisam-recover options (if present)
ERROR: Unable to start MySQL server:
mysqld: Can't read dir of '/etc/mysql/mariadb.conf.d/' (Errcode: 2 - No such file or directory)
2020-03-24T11:41:39.379271Z 0 [Note] mysqld (mysqld 5.7.29-0ubuntu0.18.04.1-log) starting as process 1856 ...
2020-03-24T11:41:39.381242Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
2020-03-24T11:41:39.381859Z 0 [ERROR] Aborting
2020-03-24T11:41:39.381970Z 0 [Note] Binlog end
Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
Once the problem is resolved, run apt-get --fix-broken install to retry.
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess 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
Processing triggers for libc-bin (2.27-3ubuntu1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
root#honeyfrost:/# apt-get --fix-broken install
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.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.29-0ubuntu0.18.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
ERROR: Unable to start MySQL server:
mysqld: Can't read dir of '/etc/mysql/mariadb.conf.d/' (Errcode: 2 - No such file or directory)
2020-03-24T11:42:48.824469Z 0 [Note] mysqld (mysqld 5.7.29-0ubuntu0.18.04.1-log) starting as process 2754 ...
2020-03-24T11:42:48.827477Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
2020-03-24T11:42:48.828517Z 0 [ERROR] Aborting
2020-03-24T11:42:48.828544Z 0 [Note] Binlog end
Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
Once the problem is resolved, run apt-get --fix-broken install to retry.
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess 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
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)
If i then run sudo systemctl start mysql, this comes up:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
And if i check the status by doing sudo systemctl status mysql, this comes up:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-03-24 12:46:55 CET; 1min 2s ago
Process: 2930 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Mar 24 12:46:55 honeyfrost systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Mar 24 12:46:55 honeyfrost systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Mar 24 12:46:55 honeyfrost systemd[1]: Stopped MySQL Community Server.
Mar 24 12:46:55 honeyfrost systemd[1]: mysql.service: Start request repeated too quickly.
Mar 24 12:46:55 honeyfrost systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 24 12:46:55 honeyfrost systemd[1]: Failed to start MySQL Community Server.
I've searched on google for hours now, but I can't find anything that works. I've tried deleting all folders associated with mysql, but the problem still persists! Help please
EDIT: When doing sudo apt-get purge *mariadb*, I get an error when trying to purge mariadb-server-10.4
The following packages will be REMOVED:
mariadb-server-10.4*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 131562 files and directories currently installed.)
Purging configuration files for mariadb-server-10.4 (1:10.4.12+maria~bionic) ...
find: ‘/var/lib/mysql’: No such file or directory
dpkg: error processing package mariadb-server-10.4 (--purge):
installed mariadb-server-10.4 package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
mariadb-server-10.4
E: Sub-process /usr/bin/dpkg returned an error code (1)

Can't install MySQL on Ubuntu 16.04

I installed mariadb-server before installing mysql-server (which I wasn't supposed to do), so I purged mariadb* and removed it from the repos. However, I can't install mysql-server.
After sudo apt-get install mysql-server, I get:
Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ...
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] invoke-rc.d: could not determine current runlevel
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.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-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
Processing triggers for libc-bin (2.23-0ubuntu9) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (229-4ubuntu19) ...
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)
After running sudo apt-get install -f, I get:
Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ...
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] Renaming removed key_buffer and myisam-recover options (if present)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] invoke-rc.d: could not determine current runlevel
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.
mysql_upgrade failed with exit status 11
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
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)
How do I get around these errors and install mysql-server?
I got it to work by deleting all the MySQL files, which weren't deleted by apt-get purge mysql*:
sudo rm -rf /var/lib/mysql/mysql

Installation Error Mysql to Debian on BeagleBone

When logging in through mysql -u root -i, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I've tried sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5, I've auto removed, cleaned, removed all associated files. After all that, I did a sudo apt-get remove --purge mysql* just to be safe. Then I installed it again: sudo apt-get install mysql-server
I get an error during the installation:
Setting up libmysqlclient18:armhf (5.5.43-0+deb7u1) ...
Setting up libdbd-mysql-perl (4.021-1+b1) ...
Setting up mysql-client-5.5 (5.5.43-0+deb7u1) ...
Setting up mysql-server-core-5.5 (5.5.43-0+deb7u1) ...
Setting up mysql-server-5.5 (5.5.43-0+deb7u1) ...
[ ok ] Stopping mysql (via systemctl): mysql.service.
[....] Starting mysql (via systemctl): mysql.serviceJob failed. See system journal and 'systemctl status' for details.
failed!
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
E: Sub-process /usr/bin/dpkg returned an error code (1)
I'm not really sure what else I can do.
So I guess the purge and installation worked. On one last whim, I decided to reboot my BeagleBone and try again. It worked.