How can Upgrade MySQL 5.5.40 to MySQL 5.7 - mysql

How can I Upgrade MySQL version
Current MySQL Version: 5.5.40
Target MySQL Version: MySQL 5.7
OS: CentOS release 6.5 (Final)

Probably the quickest way is to dump your older DB version with mysqldump and restore it into 5.7 fresh DB.
How smooth the process goes, depends on how many dropped features in 5.7 you're using in 5.5.
In my case, the only feature, that was dropped in 5.7 was timestamp default '0000-00-00 00:00:00'
The fix for that was to run sed on dump file and replace ''0000-00-00 00:00:00' with CURRENT_TIMESTAMP
sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' fixed_dumo.sql
Afterthat, the fixed_dump.sql was imported into fresh 5.7 DB and it worked smoothly.
I hope this helps.

The upgrade path is MySQL 5.5 -> MySQL 5.6 -> MySQL 5.7
See https://dev.mysql.com/doc/refman/5.7/en/upgrading.html

step 1 : take a backup
mysqldump --lock-all-tables -u root -p --all-databases > dump.sql
step 2 : remove old mysql
sudo apt-get remove mysql-server
sudo apt-get autoremove
step 3 : install new version of mysql 5.6
sudo apt-get install mysql-client-5.6 mysql-client-core-5.6
sudo apt-get install mysql-server-5.6
for 5.7
wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
step 4 : edit your data to address differences between versions (5.5 and 5.7)
If you have create table and timestamp(6) column is used than default values should be changed from CURRENT_TIMESTAMP to CURRENT_TIMESTAMP(6)
`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
step 5 : restore your data
mysql -u root -p < dump.sql
step 6 : Try to add a new db user. To validate and fix issues introduced from import of system tables like users (ERROR 1805 (HY000): Column count of mysql.user is wrong.)
mysql_upgrade -u root -p

I might be late to the party, but easy and fast solution without or minimal downtime could be AWS Database-Migration-Service, which can be used to upgrade your database to a different version as well as to some other server or RDS.
I have tried this and converted MySQL5.5 to MySQL5.7 on production without any downtime.
Here is a demo for the same - How To Migrate MySQL5.5 to MySQL5.7
Steps:
Set your current MySQL as master
Create a new instance/server with MySQL5.7 on it with required users
Got to AWS DatabaseMigrationService (DMS) and create a Replication
instance
After creating replication instance it will ask to fill up connection
detail to source(MySQL5.5) and target(MySQL5.7) databases.
Create task in DMS, which will be the logic on what basis you want to
migrate the data (particular database or particular table)
Start the task
When task is completed and data is in sync, just switch the DNS entry
pointing to MySQL5.5 to MySQL5.7

Yes. From a "logical upgrade" you can migrate from 5.5 for 5.7. This way: 5.5 -> 5.6 -> 5.7, is necessary only for "in place" upgrade, with data folder.
See: https://www.percona.com/forums/questions-discussions/mysql-and-percona-server/43956-what-is-the-preferred-mysql-upgrade-path-5-5-to-5-7

Fallow Simple Steps for Upgrade Mysql Version 5.5 to 5.7 .
wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.0-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server

After a bunch of failed attempts I have concluded it down to:
To upgrade from 5.5, go to 5.6 first and then to 5.7
Save the datafolders and install a fresh installation of 5.7
Both need the apt-config mentioned in all above comments.
The kicker is to run sudo apt install mysql-**community**-server

in Mysql,
step 1: fetch version,
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
step 2:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
step 3:
check available mysql repo,
yum repolist all | grep mysql
will get something like below,
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 384
mysql57-community-source MySQL 5.7 Community Server - S disabled
Its preferred to upgrade one by one,
so first upgrade into mysql 5.5 into mysql5.6
step 4: first enable to mysql 5.6 and disable mysql 5.5 and 5.7
sudo yum-config-manager --enable mysql56-community
sudo yum-config-manager --disable mysql55-community
sudo yum-config-manager --disable mysql57-community
step 5: before upgrade stop service,
sudo systemctl stop mysql
step 6: Lets ready to upgrade,
yum update
you are successfully upgrade into mysql5.6
now repeat step 4 to 6 to upgrade into 5.7
sudo yum-config-manager --disable mysql56-community
sudo yum-config-manager --enable mysql57-community
and then
yum update
mysql --version
successfully upgraded into mysql 5.7 dont forgot restart service,
systemctl start mysql

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server-5.6

Related

When Ubuntu 18.04 deploys zabbix4.0, the database type is PostgreSQL instead of MySQL. How can I set this to support MySQL?

In Ubuntu 18.04 server, I use binary file to install zabbix4.0 according to the official website document of zabbix4.0, and I use MySQL 5.7.30 database. After installation, when I configure the front end of zabbix4.0,In the database configuration page, I only see one option of PostgreSQL, not mysql, as shown in the following figure:
In my server, I have installed MySQL version 5.7.30, and imported the data of ZABBIX 4.0 into the ZABBIX database, without any PostgreSQL installed
Excuse me, how can I make zabbix4.0 support MySQL 5.7.30 that I have installed? Thank you!
I installed zabbix4.0 according to the official documents:
https://www.zabbix.com/documentation/4.0/zh/manual/installation/install_from_packages/debian_ubuntu
This is my installation method:
# install zabbix
cd ~/download
wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-
release/zabbix-release_ 4.0-2+bionic_ all.deb
sudo dpkg -i zabbix-release_ 4.0-2+bionic_ all.deb
sudo apt-get update
#install Server/proxy/
sudo apt-get install -y zabbix-server-mysql
sudo apt-get install -y zabbix-frontend-php
With Ubuntu, you got two type of databases when donwloading Zabbix, PostgreSql and MySql. You need to re-download (I mean installation and configuration) Zabbix choosing MySql as database.
The following link could help Zabbix (Ubuntu) with MySql as database
The current version of the package is 4.0-3, so instead, you must do this :
Install repository
# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb
# sudo dpkg -i zabbix-release_4.0-3+bionic_all.deb
# sudo apt update
Install server, frontend, agent
# sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Problems installing MySQL 5.7 properly on fresh CentOS 7 install

I admit that I am new to back-end work in general and I seem to be stuck (for several hours) following through with completing the setting up process for Magento 2.3
I was following https://devdocs.magento.com/guides/v2.3/install-gde/prereq/mysql.html for my commands but to no success.
I managed to get the following installed:
Cent OS 7 (x86_64)
Apache 2.4.6
PHP 7.2.14 (all the extensions installed passed the Setup Wizard readiness check)
I used these commands to install MySQL 5.7 Community Release: (from the documentation)
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum -y install mysql mysql-server
yum -y install mysql-community-server
To check if my installation went well, when I run:
mysql --version
I received an error message saying:
-bash: /usr/bin/mysql: No such file or directory
I know that there is something I definitely am missing out completely. When I try to start the MySQL service using the command:
systemctl start mysqld
I get the resulting error message:
Failed to start mysqld.service: Unit not found.
Any suggestions will much be appreciated. Thank you in advance.
Maybe it installed it as mariadb?
systemctl start mariadb
After removing MySQL 5.7 community release from my Cent OS, I decided to install MariaDB.
Inside the directory /etc/yum.repos.d/ I've created a file called MariaDB.repo and added this into the file:
# MariaDB 10.3 CentOS repository list - created 2019-01-25 05:36 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
I then performed the command in my terminal window:
sudo yum install MariaDB-server MariaDB-client
Because of this, mysql --version and systemctl start mysql works like a charm. Thanks #greenberet123 and #danblack for the suggestion.

Debian 9 how to install MariaDB without MySQL nameing?

I'm going thru this instrucion, trying to keep data collected from DHT22 temperatur/humidity sensor on my RaspberryPi2 with Raspbian (Debian9) onboard.
But when it comes to install and use of the DB server, when i try to install MySQL, apt-get installs MariaDB.
From this and this link I know why, but i don't want to use MySQL name in my later scripts if my procedures really uses MariaDB.
So please tell my how change below commands to instal MariaDB directly, and login to DB interface without using MySQL name:
sudo apt-get install mysql-server python-mysqldb
mysql -u root -p -h localhost
With those commands MariaDb is the default install for Debain 9. So all you need to do now is
apt-get install phpmyadmin and mysql_secure_installation. Then you can login and access the interface at localhost/phpmyadmin

Mysql version is different in phpmyadmin

I just upgraded my MYSQL version from
5.5.40 to 5.6.22
but my PHPMYADMIN still show the same old version on Home Page
In terminal I checked version
mysql --version ==> 5.6.22
But when I check with "select version()" command inside Terminal and PHPMYADMIN
I got correct version 5.6.22
But on home page of PHPMYADMIN I get 5.5.40-0ubuntu0.14.04.1 - (Ubuntu)
In a post I read that there might be two mysql clients installed and may be phpmyadmin is referring to old client. If this is the case how can I delete old-client
Try removing php-mysql and installing php-mysqlnd. Will automatically done by following commands
sudo add-apt-repository ppa:nijel/phpmyadmin
sudo apt-get update
sudo apt-get install php5-mysqlnd
sudo apt-get --purge --reinstall install phpmyadmin
Or you can try reinstalling your phpmyadmin

Update MySQL version from 5.1 to 5.5 in CentOS 6.2

I tried to update MySQL from 5.1 to 5.5 in CentOS 6.2. The following is the process I did:
1. rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
2. yum install libmysqlclient15 --enablerepo=webtatic
3. yum remove mysql mysql-*
4. yum install mysql55 mysql55-server --enablerepo=webtatic
When I tried the 4th step, I got the following output:
[root#d2005 /]# yum install mysql55 mysql55-server --enablerepo=webtatic
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: yum.singlehop.com
* extras: centos.mirrors.tds.net
* updates: pubmirrors.reflected.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql55.x86_64 0:5.5.10-1.w5 will be installed
--> Processing Dependency: mysql55-libs = 5.5.10-1.w5 for package: mysql55-5.5.10-1.w5.x86_64
---> Package mysql55-server.x86_64 0:5.5.10-1.w5 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: mysql55-server-5.5.10-1.w5.x86_64
--> Running transaction check
---> Package mysql55-libs.x86_64 0:5.5.10-1.w5 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.61-1.el6_2.1 will be installed
--> Processing Conflict: mysql55-libs-5.5.10-1.w5.x86_64 conflicts mysql-libs < 5.5.10
--> Finished Dependency Resolution
Error: mysql55-libs conflicts with mysql-libs
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
How to fix it?
To list Old MySql
yum list installed | grep -i mysql
To remove Old MySql
yum remove mysql mysql-*
Remi Dependency on CentOS 6 and Red Hat (RHEL) 6
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install MySQL server
yum --enablerepo=remi,remi-test install mysql mysql-server
To list New MySql
yum list installed | grep -i mysql
start MySql server
/etc/init.d/mysqld start ## use restart after update
OR
service mysqld start ## use restart after update
chkconfig --levels 235 mysqld on
Last
mysql_upgrade -u root -p
Now my MySql version is 5.5.32
Ref:
http://www.webtatic.com/packages/mysql55/
http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/
Hope it help some one
NOTE:
Adding comments from #pim (in comments)
Just wanted to add that after the upgrade, my crontab was removed as well. Had to reinstall with "yum install vixie-cron" (CentOS 6)
I used the following commands to add a new YUM repo and make the update:
Download the Remi repo
cd /etc/yum.repos.d
wget http://rpms.famillecollet.com/enterprise/remi.repo
Install/Update the mysql version
yum --enablerepo=remi install mysql-server
OR
yum --enablerepo=remi update mysql-server
You appear to have been using the wrong Webtatic Yum repository version than the one for your version of CentOS. See http://www.webtatic.com/projects/yum-repository/ for details
e.g.
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
You can use a yum plugin made by the IUS community to switch mysql-libs with mysql55w-libs. (the following assuming you still use Webtatic)
yum install mysql yum-plugin-replace
yum replace mysql --replace-with mysql55w
That should allow you to replace mysql with mysql55w-libs, whilst maintaining the older libmysqlclient for any dependencies.
If you see other packages than mysql being removed, then be careful, as they might be needed, but using this method, I've found to be reliable whenever I've used it.
I'm posting this solution as Remi's repository is not always the ideal solution. This method is more complex, but would never cause you to accidentally update your entire web stack by using repositories that use package names matching base distribution packages.
2015/08/19 - For those of you working on older (but still decent) hardware with a matching OS (typically 32 bit machines).
-- This will upgrade to mysql 5.6 community not 5.5 --
This worked for me after some research and mixing/matching/testing the answers found on various page of the internet (mainly from this page and http://dev.mysql.com/doc/refman/5.6/en/linux-installation-yum-repo.html).
My OS shipped with mysql 5.1, I wanted to have 5.6.
My system
[root#host]# cat /etc/*release
CentOS release 6.7 (Final)
[root#host]# uname -a
Linux host 2.6.32-573.3.1.el6.i686 #1 SMP Thu Aug 13 19:58:36 UTC 2015 i686 i686 i386 GNU/Linux
[root#host]# arch
i686
This is installed on a 2006 mac pro 1.1 (CPUs upgraded to 3.0GHz Intel Xeon X5365 Quad-Core).
Commands I ran
This was done almost immediately after a fresh install of the OS and system update via yum
list mysql currently installed
yum list installed | grep -i mysql
remove installed msql
yum remove mysql mysql-*
list mysql currently installed
yum list installed | grep -i mysql
Download rpm containing mysql 5.6
wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Install mysql
rpm -Uvh mysql-community-release-el6-5.noarch.rpm
yum install mysql mysql-server
list mysql currently installed
yum list installed | grep -i mysql
ensure mysql starts on reboot
chkconfig --list mysqld
sudo chkconfig mysqld on
chkconfig --list mysqld
Start mysql
service mysqld start
service mysqld status
Result
[root#host]# yum list installed | grep -i mysql
compat-mysql51.i686 5.1.54-1.el6.remi #remi
mysql-community-client.i686
5.6.26-2.el6 #mysql56-community
mysql-community-common.i686
5.6.26-2.el6 #mysql56-community
mysql-community-libs.i686
5.6.26-2.el6 #mysql56-community
mysql-community-release.noarch
mysql-community-server.i686
5.6.26-2.el6 #mysql56-community
perl-DBD-MySQL.i686 4.013-3.el6 #base
[root#host]# mysql --version
mysql Ver 14.14 Distrib 5.6.26, for Linux (i686) using EditLine wrapper
mysql config (I did not touch this yet but the info seems legit)
Some interesting basic but efficient performance tuning for mysql:
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-5-6-from-official-yum-repositories
Good luck!
Edit
I had some issues creating users and granting permissions, this how it was fixed.
Error
ERROR 1054 (42S22) at line 1: Unknown column 'plugin' in 'mysql.user'
Fix
Logged on the server as root
Connected to mysql with a simple mysql
Checked the outcome of this statement: SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user'; The result was 39, 43 is expected for mysql 5.6
Issued this statement to update the root password: update mysql.user set Password=PASSWORD('root') where User='root';
(Logged off mysql with exit)
Restarted mysql with: service mysqld restart
Ran: mysql_upgrade -uroot -proot --force
Reconnected to mysql with mysql -uroot -proot
Checked the outcome of this statement: SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user'; The result was 43 as expected for mysql 5.6. I was then able to create my users and grant permissions as needed.
Above replies didn't work for me (got this error - error: /var/tmp/rpm-tmp.tyukGy: not an rpm package).
I followed these steps -
## Remove existing/old MySQL ##
yum remove mysql mysql-*
rm -rf /var/lib/mysql
rm -rf /var/log/mysql*
## Install Remi Repository on RHEL/CentOS 6.7-6.0 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
## Install Remi Repository on RHEL/CentOS 5.4-5.0 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
yum --enablerepo=remi list mysql mysql-server
yum --enablerepo=remi install mysql mysql-server
Taken from - http://www.tecmint.com/install-mysql-on-rhel-centos-6-5-fedora-17-12/
By doing above, i uninstalled MySQL 5.0.* and replaced it with this -
[root#localhost]# /usr/bin/mysqladmin -u root -p version
/usr/bin/mysqladmin Ver 8.42 Distrib 5.5.28, for Linux on x86_64
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.5.28
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 32 sec
Threads: 1 Questions: 3 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.093
[root#localhost]#
My CentOS version -
[root#localhost]# cat /etc/redhat-release
CentOS release 6.3 (Final)
[root#localhost]# uname -a
Linux localhost.localdomain 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Use CentOS-Release-SCL is better and easy.
The Software Collections ( SCL ) Repository
# yum install centos-release-SCL
# yum install mysql55-mysql-server
Done.
This blog post helped me upgrade from MySQL 5.5.15 to 5.5.28. That upgrade also had the problem with mysql-libs clashing with mysql55-libs.
wget -P /etc/yum.repos.d http://rpms.famillecollet.com/enterprise/remi.repo
yum --enablerepo=remi -y install mysql-server
OR
yum --enablerepo=remi -y update mysql-server