Wednesday, September 20, 2017

Debian Jessie: change MySql distribution to MySql community

Debian Stretch does not shipped MySql. Before upgrade your Debian Jessie into Stretch, you need to change your MySql Debian distribution into MySql Community.

Install MySql dependency
# apt-get install lsb-release

Download MySql apt configuration from https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
# wget --no-check-certificate https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
Note: File name may change without notice, check latest mysql-apt-config at https://dev.mysql.com/downloads/repo/apt/

"The MySQL APT repository can only replace distributions of MySQL maintained and distributed by Debian or Ubuntu. It cannot replace any MySQL forks found either inside or outside of the distributions' native repositories. To replace such MySQL forks, you have to uninstall them first before you install MySQL using the MySQL APT repository. Follow the instructions for uninstallation from the forks' distributors and, before you proceed, make sure you back up your data and you know how to restore them to a new server. "

Backup MySql
# mysqldump --all-database > backup_all_201709.sql -u root -p

Remove your MySql Distribution
# apt-get --purge remove mysql-server mysql-client
# apt-get --purge remove mysql-server-5.5 mysql-client-5.5 // if required
# apt-get --purge remove mysql-server-core-5.5 mysql-client-core-5.5
// if required
Note: check your mysql using 

# aptitude search mysql-server

Install MySql apt configuration.
# dpkg -i mysql-apt-config_0.8.7-1_all.deb
Choose MySql 5.7 for stable version and continue by click Ok. It will create apt repository file like this:

# cat /etc/apt/sources.list.d/mysql.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/debian/ jessie mysql-apt-config
deb http://repo.mysql.com/apt/debian/ jessie mysql-5.7
deb http://repo.mysql.com/apt/debian/ jessie mysql-tools
#deb http://repo.mysql.com/apt/debian/ jessie mysql-tools-preview
deb-src http://repo.mysql.com/apt/debian/ jessie mysql-5.7


Run update and install
# apt-get update
# apt-get install mysql-server mysql-client
At the end of installation, you will be ask for MySql root password (Note: this is not root Linux user)

# service mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled)
   Active: active (running) since Wed 2017-09-20 09:24:13 WIB; 8s ago
 Main PID: 8432 (mysqld)
   CGroup: /system.slice/mysql.service
           └─8432 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...

Sep 20 09:24:13 igamdeb8 systemd[1]: Started MySQL Community Server.
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


Run mysql_upgrade:
# mysql_upgrade -u root -p
Enter password:
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.host                                         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
Upgrading the sys schema.
Checking databases.
...



Resotre your database
# mysql -u root -p < backup_all_201709.sql
Enter password:


References:
https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
https://dev.mysql.com/doc/refman/5.7/en/backup-and-recovery.html
https://dev.mysql.com/doc/refman/5.7/en/reloading-sql-format-dumps.html

No comments:

Post a Comment