MySQL upgrade fails on Ubuntu 16.04 - mysql

I have Ubuntu 16.04 running (clean install - no upgrade). MySQL is running fine - but I get this error when I try to update MySQL:
apt-get 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.16-0ubuntu0.16.04.1) ...
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
The sys schema is already up to date (version 1.5.1).
Checking databases.
ALL DATABASES RETURNED OK
Error occurred: Error during call to mysql_check.
mysql_upgrade failed with exit status 4
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
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Although it's running, I dont like errors. Do you guys have any idea how to fix this issue?
Running dpkg -l | grep mysql gives:
dpkg -l | grep mysql
ii libdbd-mysql-perl 4.033-1ubuntu0.1 amd64 Perl5 database interface to the MySQL database
ii libmysqlclient20:amd64 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database client library
ii mysql-client 5.7.16-0ubuntu0.16.04.1 all MySQL database client (metapackage depending on the latest version)
ii mysql-client-5.7 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database client binaries
ii mysql-client-core-5.7 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database core client binaries
ii mysql-common 5.7.16-0ubuntu0.16.04.1 all MySQL database common files, e.g. /etc/mysql/my.cnf
iU mysql-server 5.7.16-0ubuntu0.16.04.1 all MySQL database server (metapackage depending on the latest version)
iF mysql-server-5.7 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.7 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database server binaries
ii php-mysql 1:7.0+45+deb.sury.org~xenial+1 all MySQL module for PHP [default]
ii php5.6-mysql 5.6.27-1+deb.sury.org~xenial+1 amd64 MySQL module for PHP
ii php7.0-mysql 7.0.12-1+deb.sury.org~xenial+1 amd64 MySQL module for PHP
Thanks

I've run into this myself and I believe it has to do with how the upgrade process stops/starts/restarts MySQL.
Here is my workaround that I do after an attempted upgrade of MySQL fails.
Start MySQL normally, typically "service mysql start" as root.
As root execute "mysql_upgrade --defaults-file=/etc/mysql/debian.cnf". Hopefully it should complete with no errors or indicate that MySQL is already upgraded.
Edit the file "/var/lib/dpkg/info/mysql-server-5.7.postinst" with your favorite editor. Around line 320 (depending on version) find the line "mysql_upgrade --defaults-file=/etc/mysql/debian.cnf || result=$?". Comment that line out (prepend line with '#'), if should look like "#mysql_upgrade --defaults-file=/etc/mysql/debian.cnf || result=$?". Save the file and exit from the editor.
Rerun the upgrade process and it should indicate that MySQL is now upgraded.
At some point I will dig further to see why the "mysql_upgrade ..." invocation fails during the upgrade but not alone from the command line. But I've not gone through a few iterations of upgrades without issue using this method.
Hope this helps.
'Grip

I've had this issue before, the root cause for this issue was changing the db configuration.
I changed lower_case_table_names = 1 and set the value to one, and when I tried to upgrade it failed with the error you shared in your question.
To solve it, I simple set the value back to 0, restarted the db, and the upgrade worked well for me.
First edit the config:
sudo nano /etc/mysql/my.cnf
change this line:
lower_case_table_names = 0
restart the database
sudo /etc/init.d/mysql restart
Then run the upgrade command

NOTE: This is for upgrading MySQL with "mysql_secure_installation" fix.
Had problems with upgrading MySQL Server 5.7 in Ubuntu 16.04 and I finally located my problem. I enabled "mysql_secure_installation" during my first installation that causes the upgrade script to fail due to password creation error (unsatisfied special character requirement on the automatically generated password in the upgrade script).
While running 'sudo apt upgrade' or 'sudo apt install -f', the error can be traced using this command:
tail -f /var/log/mysql/error.log
In my case, the log shows:
[ERROR] 1819 Your password does not satisfy the current policy
requirements
To fix this, login to mysql and temporarily disable MySQL's validate password plugin:
mysql -u root -p -h 127.0.0.1
mysql> uninstall plugin validate_password;
mysql> exit
make sure to stop the previous upgrade/install and rerun the upgrade/install. Once done, login back to mysql and enable MySQL's validate password plugin;
mysql -u root -p -h 127.0.0.1
mysql> install plugin validate_password SONAME 'validate_password.so';
mysql> exit

always check /var/log/mysqld.log first

Related

Unatttended MySQL 8 community install on Ubuntu 18.04 WSL

I am trying to install MySQL 8 on an Ubuntu (that is a Windows Subsystem for Linux) without any prompts.
I have the following script:
apt-key add --keyserver pgp.mit.edu --recv-keys 5072E1F5
echo 'deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0' > /etc/apt/sources.list.d/mysql.list
apt-get update --yes
apt-get install --yes debconf-utils
echo 'mysql-community-server mysql-community-server/root-pass password' | sudo debconf-set-selections
echo 'mysql-community-server mysql-community-server/re-root-pass password' | sudo debconf-set-selections
apt-get install --yes mysql-community-server
(partly constructed thanks to the answers in this question)
and it appears to work fine, except that it prompts me to select authentication method... I want to pick the mysql_native_password and do so without being prompted interactively.
I'm guessing the solution is another debconf-set-selections setting, but... In addition to asking what is it for this case... Is there a reference of all possible options somewhere?
There's also the issue that apt-get says that a symlink is created for the service, and yet the service isn't created... But that's not really a showstopper, as I'm using WSL merely as a test ground for an actual Ubuntu server, where I'd think this would work... hopefully.
EDIT1: Nevermind the original question... I managed to find an answer here
which led to stumble upon this dockerfile
So I ended up adding
echo 'mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)' | sudo debconf-set-selections
is the line I need...
HOWEVER, the other, possibly WSL specific issue remains... that is, no MySQL service is created. I should note that while I have MySQL outside of WSL, the server is turned off, specifically so that the WSL could run.
I get the following output upon the install, near the end:
Setting up mysql-community-server (8.0.16-2ubuntu18.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
mysql-community-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
And the only thing I can find related to that is suggestions of complete reinstall, but even reinstalling the WSL instance doesn't fix this.
EDIT2: Adding
apt-get dist-upgrade --yes --allow-remove-essential --allow-change-held-packages
Fixes the above error, and yet despite there not being any errors, the service is still not created.
I sort of fixed the missing mysql service by copying the /etc/init.d/mysql file from another WSL instance (mysql 8 installed through an upgrade) to /etc/init.d
sudo service mysql start
returns a [fail], but the mysql daemon runs just fine.
Otherwise, I've seen people achieve this more cleanly by installing a lower version from MySQL's repo first, and then upgrade to mysql 8.

Can't Installing mysql in Linux mint 19

I am a beginner Linux user. Yesterday, I tried to install MySQL on my Linux mint laptop. I have installed Apache successfully, but I have got the following errors while trying to install MySQL.
Setting up mysql-server-5.7 (5.7.25-0ubuntu0.18.04.2) ...
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)
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.
Processing triggers for systemd (237-3ubuntu10.17) ...
Processing triggers for ureadahead (0.100.0-20) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
I have tried to find a way again from the web but nothing works and I can't sleep because of this..:(
I installed MySQL on Mint numerous times, but I recently started to have the same problem - all out of the blue.
Try the steps here:
https://vitux.com/how-to-install-and-configure-mysql-in-ubuntu-18-04-lts/
sudo apt-get update
sudo apt-get install mysql-server
sudo mysql_secure_installation
You will have a few yes and no options for your MySQL server. Choose as appropriate for you, then log in using sudo mysql, not just mysql
sudo mysql -uroot -p
The prompt will change from whatever your linux login user is to mysql>
For a list of the users automatically created:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
Change the authentication method for root user, and assign a new password if you want:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Now you will be able to access MySQL server from MySQL workbench. In all honesty, I suggest to use that because it makes your life much easier.

FreeBSD MySQL error after installation

I am on FreeBSD 10.2 32 bit and installed the newest version of mysql with the following command:
pkg install mysql57-server-5.7.12
Now, when I try to start mysql:
service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
I am getting this error. I hope you can help me.
Check your /var/db/mysql folder, if it contains files, make a backup and delete dir content:
rm -rf /var/db/mysql/*
Then do a data directory initialization:
/usr/local/libexec/mysqld --initialize --user=mysql
You should get a new temporary password, write it down, then start mysql-server
service mysql-server start
After mysql starts, secure the installation via:
/usr/local/bin/mysql_secure_installation
Open /etc/rc.conf and append or modify this line :
mysql_enable="YES"
Save the file, close it and retry to start the server.

apt-get upgrade always fails on mariadb-server due to timezone

MariaDB 10.1.3, kernel 3.19.3, Debian
Problem: apt-get upgrade always fails due to mariadb-server timezone issue.
my.cnf contains
[mysqld]
default_time_zone=America/New_York
I also imported the tzinfo:
# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
When I manually stop/start the service, there is no issue:
# service mysql restart
[ ok ] Stopping MariaDB database server: mysqld.
[ ok ] Starting MariaDB database server: mysqld ..
[info] Checking for corrupt, not cleanly closed and upgrade needing tables..
However, every single time I run apt-get upgrade, it always fails on mariadb-server:
# apt-get upgrade
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.
Do you want to continue [Y/n]?
Setting up mariadb-server-10.1 (10.1.3+maria-1~wheezy) ...
[ ok ] Stopping MariaDB database server: mysqld.
dpkg: error processing mariadb-server-10.1 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mariadb-server:
mariadb-server depends on mariadb-server-10.1 (= 10.1.3+maria-1~wheezy); however:
Package mariadb-server-10.1 is not configured yet.
dpkg: error processing mariadb-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mariadb-server-10.1
mariadb-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
The error is:
# tail /var/log/syslog
mysqld_safe[32269]: [ERROR] Fatal error: Illegal or unknown default time zone 'America/New_York'
This is happening on multiple servers and has become a real annoyance. Could use your help. BTW, it isn't the MariaDB version, as this error has persisted for a couple of years throughout several versions.
EDIT TO ADD: I forgot to mention if I remove the default_time_zone parameter from my.cnf, apt-get upgrade does work. It is only when that parameter is present that apt-get upgrade fails. It needs to be present for my configuration.
EDIT 2: To ensure clarity, even after removing default_time_zone, then doing apt-get upgrade successfully, then adding back default_time_zone and restarting -- future mariadb-* upgrades will fail via apt. There is something specific to the process during apt-get upgrades that is not consistent with a normal service start.
Had the same issue. This is what worked for me:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo apt-get install mariadb-server
Backup /var/lib/mysql folder, as all data in will be deleted
Perhaps the answer is "The MySQL installation procedure creates the time zone tables in the mysql database, but does not load them. You must do so manually using the following instructions..."
See Manual page.
You may choose to file a bug report about the installation error, too.

Upgrade to MariaDB 10 from MariaDB 5.5 via yum fails

I want to upgrade mariadb from 5.5... to 10. But when I run "yum update -y", screen show like below:
Upgrading directly from MySQL <unrecognized version package MariaDB-server-5.5.36-1.el6.x86_64
MariaDB-server-5.5.36-1.el6.x86_64 is not installed> to MariaDB 10.0 may not
be safe in all cases. A manual dump and restore using mysqldump is
recommended. It is important to review the MariaDB manual's Upgrading
section for version-specific incompatibilities.
A manual upgrade is required.
- Ensure that you have a complete, working backup of your data and my.cnf
files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages. Usually this command will
list the packages you should remove:
rpm -qa | grep -i '^mysql-'
You may choose to use 'rpm --nodeps -ev <package-name>' to remove
the package which contains the mysqlclient shared library. The
library will be reinstalled by the MariaDB-shared package.
- Install the new MariaDB packages supplied by Monty Program AB
- Ensure that the MariaDB server is started
- Run the 'mysql_upgrade' program
How can I fix this issue?
I fix by myself, I post here for anyone need:
I run,
rpm -qa | grep -i '^maria'
Screen show:
MariaDB-common-10.0.12-1
MariaDB-client-10.0.12-1
MariaDB-server-5.5.38-1
MariaDB-shared-10.0.12-1
My "MariaDB-server" is still 5.5, I stop and remove it (backup all before do change anything):
yum remove MariaDB-server
then install again:
yum install MariaDB-server
screen:
Total size: 56 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : MariaDB-server 1/1
Installed:
MariaDB-server.i386 0:10.0.12-1
run again:
rpm -qa | grep -i '^maria'
screen show:
MariaDB-common-10.0.12-1
MariaDB-client-10.0.12-1
MariaDB-server-10.0.12-1
MariaDB-shared-10.0.12-1
It's OK.
I recently found steps on the official MariaDB website for upgrading to the latest stable version.
under /etc/yum.repos.d/ add MariaDB.repo with the following configs:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Run sudo yum install MariaDB-server MariaDB-client
Full steps can be found in this tutorial