Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
MySQL 8 Cookbook
MySQL 8 Cookbook

MySQL 8 Cookbook: Over 150 recipes for high-performance database querying and administration

Arrow left icon
Profile Icon Karthik Appigatla
Arrow right icon
Can$69.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (4 Ratings)
Paperback Jan 2018 446 pages 1st Edition
eBook
Can$38.99 Can$55.99
Paperback
Can$69.99
Subscription
Free Trial
Arrow left icon
Profile Icon Karthik Appigatla
Arrow right icon
Can$69.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (4 Ratings)
Paperback Jan 2018 446 pages 1st Edition
eBook
Can$38.99 Can$55.99
Paperback
Can$69.99
Subscription
Free Trial
eBook
Can$38.99 Can$55.99
Paperback
Can$69.99
Subscription
Free Trial

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

MySQL 8 Cookbook

MySQL 8 - Installing and Upgrading

In this chapter, we will cover the following recipes:

  • Installing MySQL using YUM/APT
  • Installing MySQL 8.0 using RPM or DEB files
  • Installing MySQL on Linux using Generic Binaries
  • Starting or Stopping MySQL 8
  • Uninstalling MySQL 8
  • Managing MySQL Server with systemd
  • Downgrading from MySQL 8.0
  • Upgrading to MySQL 8.0
  • Installing MySQL utilities

Introduction

In this chapter, you will learn about the installing, upgrading, and downgrading steps of MySQL 8. There are five different ways to install or upgrade; the three most widely-used installation methods are covered in this chapter:

  • Software repositories (YUM or APT)
  • RPM or DEB files
  • Generic Binaries
  • Docker (not covered)
  • Source code compilation (not covered)

If you have already installed MySQL and want to upgrade, go through the upgrade steps in the Upgrade to MySQL 8 section. If your installation is corrupt, go through the uninstallation steps also in the Upgrade to MySQL 8 section.

Before installation, make a note of OS and CPU architecture. The convention followed is as follows:

MySQL Linux RPM package distribution identifiers

Distribution value

Intended use

el6, el7

Red Hat Enterprise Linux, Oracle Linux, CentOS 6 or 7

fc23, fc24, fc25

Fedora 23, 24, or 25

sles12

SUSE Linux Enterprise Server 12

MySQL Linux RPM package CPU identifiers

CPU value

Intended processor type or family

i386, i586, i686

Pentium processor or better, 32-bit

x86_64

64-bit x86 processor

ia64

Itanium (IA-64) processor

MySQL Debian and Ubuntu 7 and 8 installation packages CPU identifiers

CPU value

Intended processor type or family

i386

Pentium processor or better, 32-bit

amd64

64-bit x86 processor

MySQL Debian 6 Installation package CPU identifiers

CPU value

Intended processor type or family

i686

Pentium processor or better, 32-bit

x86_64

64-bit x86 processor

Installing MySQL using YUM/APT

The most common and easiest way of installation is through software repositories where you add official Oracle MySQL repositories to your list and install MySQL through package management software.

There are mainly two types of repository software:

  • YUM (Centos, Red Hat, Fedora and Oracle Linux)
  • APT (Debian, Ubuntu)

How to do it...

Let's look at steps for installing MySQL 8 in the following ways:

Using YUM repositories

  1. Find the Red Hat or CentOS version:
shell> cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
  1. Add the MySQL Yum repository to your system's repository list. This is a one-time operation that can be performed by installing an RPM provided by MySQL.
    You can download the MySQL YUM Repository from http://dev.mysql.com/downloads/repo/yum/ and choose the file depending on your OS.
    Install the downloaded release package with the following command, replacing the name with the platform- and version-specific package name of the downloaded RPM package:
shell> sudo yum localinstall -y mysql57-community-release-el7-11.noarch.rpm
Loaded plugins: fastestmirror
Examining mysql57-community-release-el7-11.noarch.rpm: mysql57-community-release-el7-11.noarch
Marking mysql57-community-release-el7-11.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-11 will be installed
--> Finished Dependency Resolution
~
Verifying : mysql57-community-release-el7-11.noarch 1/1

Installed:
mysql57-community-release.noarch 0:el7-11
Complete!
  1. Or you can copy the link location and install directly using RPM (you can skip the next step after installing):
shell> sudo rpm -Uvh "https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm"
Retrieving https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-11 ################################# [100%]
  1. Verify the installation:
shell> yum repolist enabled | grep 'mysql.*-community.*'
mysql-connectors-community/x86_64 MySQL Connectors Community 42
mysql-tools-community/x86_64 MySQL Tools Community 53
mysql57-community/x86_64 MySQL 5.7 Community Server 227
  1. Set the release series. At the time of writing this book, MySQL 8 is not a general availability (GA) release. So MySQL 5.7 will be selected as the default release series. To install MySQL 8, you have to set the release series to 8:
shell> sudo yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 42
mysql-connectors-community-source MySQL Connectors Community disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 53
mysql-tools-community-source MySQL Tools Community - Sou disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Sourc disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 227
mysql57-community-source MySQL 5.7 Community Server disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server disabled
  1. Disable mysql57-community and enable mysql80-community:
shell> sudo yum install yum-utils.noarch -y
shell> sudo yum-config-manager --disable mysql57-community
shell> sudo yum-config-manager --enable mysql80-community
  1. Verify that mysql80-community is enabled:
shell> sudo yum repolist all | grep mysql8
mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 16
mysql80-community-source MySQL 8.0 Community Server disabled
  1. Install MySQL 8:
shell> sudo yum install -y mysql-community-server
Loaded plugins: fastestmirror
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql80-community | 2.5 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirror.web-ster.com
* epel: mirrors.cat.pdx.edu
* extras: mirrors.oit.uci.edu
* updates: repos.lax.quadranet.com
Resolving Dependencies
~
Transaction test succeeded
Running transaction
Installing : mysql-community-common-8.0.3-0.1.rc.el7.x86_64 1/4
Installing : mysql-community-libs-8.0.3-0.1.rc.el7.x86_64 2/4
Installing : mysql-community-client-8.0.3-0.1.rc.el7.x86_64 3/4
Installing : mysql-community-server-8.0.3-0.1.rc.el7.x86_64 4/4
Verifying : mysql-community-libs-8.0.3-0.1.rc.el7.x86_64 1/4
Verifying : mysql-community-common-8.0.3-0.1.rc.el7.x86_64 2/4
Verifying : mysql-community-client-8.0.3-0.1.rc.el7.x86_64 3/4
Verifying : mysql-community-server-8.0.3-0.1.rc.el7.x86_64 4/4

Installed:
mysql-community-server.x86_64 0:8.0.3-0.1.rc.el7
Dependency Installed:
mysql-community-client.x86_64 0:8.0.3-0.1.rc.el7
mysql-community-common.x86_64 0:8.0.3-0.1.rc.el7
mysql-community-libs.x86_64 0:8.0.3-0.1.rc.el7

Complete!
  1. You can check the installed packages using the following:
shell> rpm -qa | grep -i 'mysql.*8.*'
perl-DBD-MySQL-4.023-5.el7.x86_64
mysql-community-libs-8.0.3-0.1.rc.el7.x86_64
mysql-community-common-8.0.3-0.1.rc.el7.x86_64
mysql-community-client-8.0.3-0.1.rc.el7.x86_64
mysql-community-server-8.0.3-0.1.rc.el7.x86_64

Using APT repositories

  1. Add the MySQL APT repository to your system's repository list. This is a one-time operation that can be performed by installing a .deb file provided by MySQL
    You can download the MySQL APT repository from http://dev.mysql.com/downloads/repo/apt/.
    Or you can copy the link location and use wget to download directly on to the server. You might need to install wget (sudo apt-get install wget):
shell> wget "https://repo.mysql.com//mysql-apt-config_0.8.9-1_all.deb"
  1. Install the downloaded release package with the following command, replacing  the name with platform- and version-specific package name of the downloaded APT package:
shell> sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb 
(Reading database ... 131133 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.9-1_all.deb ...
Unpacking mysql-apt-config (0.8.9-1) over (0.8.9-1) ...
Setting up mysql-apt-config (0.8.9-1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK
  1. During the installation of the package, you will be asked to choose the versions of the MySQL server and other components. Press Enter for selecting and the Up and Down keys for navigating.
    Select MySQL Server and Cluster (Currently selected: mysql-5.7).
    Select mysql-8.0 preview (At the time of writing, MySQL 8.0 is not GA). You might get a warning such as MySQL 8.0-RC Note that MySQL 8.0 is currently an RC. It should only be installed to preview upcoming features of MySQL, and is not recommended for use in production environments(RC is short for release candidate).
    If you want to change the release version, execute the following:
shell> sudo dpkg-reconfigure mysql-apt-config
  1. Update package information from the MySQL APT repository with the following command (this step is mandatory):
shell> sudo apt-get update
  1. Install MySQL. During installation, you'll need to provide a password for the root user for your MySQL installation. Remember the password; if you forget it, you'll have to reset the root password (refer to the Resetting root password section). This installs the package for the MySQL server, as well as the packages for the client and for the database common files:
shell> sudo apt-get install -y mysql-community-server
~
Processing triggers for ureadahead (0.100.0-19) ...
Setting up mysql-common (8.0.3-rc-1ubuntu14.04) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up mysql-community-client-core (8.0.3-rc-1ubuntu14.04) ...
Setting up mysql-community-server-core (8.0.3-rc-1ubuntu14.04) ...
~
  1. Verify packages. ii indicates that the package is installed:
shell> dpkg -l | grep -i mysql
ii mysql-apt-config 0.8.9-1 all Auto configuration for MySQL APT Repo.
ii mysql-client 8.0.3-rc-1ubuntu14.04 amd64 MySQL Client meta package depending on latest version
ii mysql-common 8.0.3-rc-1ubuntu14.04 amd64 MySQL Common
ii mysql-community-client 8.0.3-rc-1ubuntu14.04 amd64 MySQL Client
ii mysql-community-client-core 8.0.3-rc-1ubuntu14.04 amd64 MySQL Client Core Binaries
ii mysql-community-server 8.0.3-rc-1ubuntu14.04 amd64 MySQL Server
ii mysql-community-server-core 8.0.3-rc-1ubuntu14.04 amd64 MySQL Server Core Binaires

Installing MySQL 8.0 using RPM or DEB files

Installing MySQL using repositories requires access to public internet. As a security measure, most of the production machines are not connected to the internet. In that case, you can download the RPM or DEB files on the system administration and copy them to the production machine.

There are mainly two types of installation files:

  • RPM (CentOS, Red Hat, Fedora, and Oracle Linux)
  • DEB (Debian, Ubuntu)

There are multiple packages that you need to install. Here is a list and short description of each one:

  • mysql-community-server: Database server and related tools.
  • mysql-community-client: MySQL client applications and tools.
  • mysql-community-common: Common files for server and client libraries.
  • mysql-community-devel: Development header files and libraries for MySQL database client applications, such as the Perl MySQL module.
  • mysql-community-libs: The shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load and use MySQL.
  • mysql-community-libs-compat: The shared libraries for older releases. Install this package if you have applications installed that are dynamically linked against older versions of MySQL but you want to upgrade to the current version without breaking the library dependencies.

How to do it...

Let's look at how to do it using the following types of bundles:

Using the RPM bundle

  1. Download the MySQL RPM tar bundle from the MySQL Downloads page, http://dev.mysql.com/downloads/mysql/, choosing your OS and CPU architecture. At the time of writing,  MySQL 8.0 is not GA. If it is still in the development series, select the Development Releases tab for getting MySQL 8.0 and the choose the OS and version:
shell> wget 'https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.3-0.1.rc.el7.x86_64.rpm-bundle.tar'
~
Saving to: ‘mysql-8.0.3-0.1.rc.el7.x86_64.rpm-bundle.tar’
~
  1. Untar the package:
shell> tar xfv mysql-8.0.3-0.1.rc.el7.x86_64.rpm-bundle.tar
  1. Install MySQL:
shell> sudo rpm -i mysql-community-{server-8,client,common,libs}*
  1. RPM cannot solve the dependency issues and the installation process might run issues. If you are facing such issues, use the yum command listed here (you should have access to dependent packages):
shell> sudo yum install mysql-community-{server-8,client,common,libs}* -y
  1. Verify the installation:
shell> rpm -qa | grep -i mysql-community
mysql-community-common-8.0.3-0.1.rc.el7.x86_64
mysql-community-libs-compat-8.0.3-0.1.rc.el7.x86_64
mysql-community-libs-8.0.3-0.1.rc.el7.x86_64
mysql-community-server-8.0.3-0.1.rc.el7.x86_64
mysql-community-client-8.0.3-0.1.rc.el7.x86_64

Using the APT bundle

  1. Download the MySQL APT TAR from the MySQL Downloads page, http://dev.mysql.com/downloads/mysql/:
shell> wget "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-server_8.0.3-rc-1ubuntu16.04_amd64.deb-bundle.tar"
~
Saving to: ‘mysql-server_8.0.3-rc-1ubuntu16.04_amd64.deb-bundle.tar’
~
  1. Untar the packages:
shell> tar -xvf mysql-server_8.0.3-rc-1ubuntu16.04_amd64.deb-bundle.tar 
  1. Install the dependencies. You may need to install the libaio1 package if it is not already installed:
shell> sudo apt-get install -y libaio1
  1. Upgrade libstdc++6 to the latest:
shell> sudo add-apt-repository ppa:ubuntu-toolchain-r/test
shell> sudo apt-get update
shell> sudo apt-get upgrade -y libstdc++6
  1. Upgrade libmecab2 to the latest. If universe is not included, then add the following line to the end of the file (for example, zesty):
shell> sudo vi /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu zesty main universe

shell> sudo apt-get update
shell> sudo apt-get install libmecab2
  1. Preconfigure the MySQL server package with the following command. It asks you to set the root password:
shell> sudo dpkg-preconfigure mysql-community-server_*.deb
  1. Install the database common files package, the client package, the client metapackage, the server package, and the server metapackage (in that order); you can do that with a single command:
shell> sudo dpkg -i mysql-{common,community-client-core,community-client,client,community-server-core,community-server,server}_*.deb
  1. Install the shared libraries:
shell> sudo dpkg -i libmysqlclient21_8.0.1-dmr-1ubuntu16.10_amd64.deb
  1. Verify the installation:
shell> dpkg -l | grep -i mysql
ii mysql-client 8.0.3-rc-1ubuntu14.04 amd64 MySQL Client meta package depending on latest version
ii mysql-common 8.0.3-rc-1ubuntu14.04 amd64 MySQL Common
ii mysql-community-client 8.0.3-rc-1ubuntu14.04 amd64 MySQL Client
ii mysql-community-client-core 8.0.3-rc-1ubuntu14.04 amd64 MySQL Client Core Binaries
ii mysql-community-server 8.0.3-rc-1ubuntu14.04 amd64 MySQL Server
ii mysql-community-server-core 8.0.3-rc-1ubuntu14.04 amd64 MySQL Server Core Binaires
ii mysql-server 8.0.3-rc-1ubuntu16.04 amd64 MySQL Server meta package depending on latest version

Installing MySQL on Linux using Generic Binaries

Installing using the software packages requires some dependencies to be installed first and can conflict with other packages. In that case, you can install MySQL using the generic binaries available on the downloads page. Binaries are precompiled using advanced compilers and are built with the best possible options for optimal performance.

How to do it...

MySQL has a dependency on the libaio library. The data directory initialization, and subsequent server startup steps, will fail if this library is not installed locally.

On YUM-based systems:

shell> sudo yum install -y libaio

On APT-based systems:

shell> sudo apt-get install -y libaio1

Download the TAR binary from the MySQL Downloads page, at https://dev.mysql.com/downloads/mysql/, then choose Linux - Generic as the OS and select the version. You can download directly onto your server directly using the wget command:

shell> cd /opt
shell> wget "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.3-rc-linux-glibc2.12-x86_64.tar.gz"

Install MySQL using the following steps:

  1. Add the mysql group and the mysql user. All the files and directories should be under the mysql user:
shell> sudo groupadd mysql
shell> sudo useradd -r -g mysql -s /bin/false mysql
  1. This is the installation location (you can change it to another location):
shell> cd /usr/local
  1. Untar the binary file. Keep the untarred binary file at the same location and symlink it to the installation location. In this way, you can keep multiple versions and it is very easy to upgrade. For example, you can download another version and untar it to a different location; while upgrading, all you need to do is to change the symlink:
shell> sudo tar zxvf /opt/mysql-8.0.3-rc-linux-glibc2.12-x86_64.tar.gz
mysql-8.0.3-rc-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-8.0.3-rc-linux-glibc2.12-x86_64/bin/myisamchk
mysql-8.0.3-rc-linux-glibc2.12-x86_64/bin/myisamlog
mysql-8.0.3-rc-linux-glibc2.12-x86_64/bin/myisampack
mysql-8.0.3-rc-linux-glibc2.12-x86_64/bin/mysql
~
  1. Make the symlink:
shell> sudo ln -s mysql-8.0.3-rc-linux-glibc2.12-x86_64 mysql
  1. Create the necessary directories and change the ownership to mysql:
shell> cd mysql
shell> sudo mkdir mysql-files
shell> sudo chmod 750 mysql-files
shell> sudo chown -R mysql .
shell> sudo chgrp -R mysql .
  1. Initialize mysql, which generates a temporary password:
shell> sudo bin/mysqld --initialize --user=mysql
~
2017-12-02T05:55:10.822139Z 5 [Note] A temporary password is generated for root@localhost: Aw=ee.rf(6Ua
~
  1. Set up the RSA for SSL. Refer to Chapter 14, Setting up Encrypted Connections using X509 Section, for more details on SSL. Note that a temporary password is generated for root@localhost: eJQdj8C*qVMq:
shell> sudo bin/mysql_ssl_rsa_setup
Generating a 2048 bit RSA private key
...........+++
....................................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
...........................................................+++
...........................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.....+++
..........................+++
writing new private key to 'client-key.pem'
-----
  1. Change the ownership of binaries to root and data files to mysql:
shell> sudo chown -R root .
shell> sudo chown -R mysql data mysql-files
  1. Copy the startup script to init.d:
shell> sudo cp support-files/mysql.server /etc/init.d/mysql
  1. Export the binary of mysql to the PATH environment variable:
shell> export PATH=$PATH:/usr/local/mysql/bin
  1. Refer to Starting or Stopping MySQL 8 section to start MySQL.

After installation, you will get the following directories inside /usr/local/mysql:

Directory

Contents of directory

bin

mysqld server, client, and utility programs

data

Log files, databases

docs

MySQL manual in info format

man

Unix manual pages

include

Include (header) files

lib

Libraries

share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

There's more...

There are other installation methods, such as:

  1. Compiling from the source code. You can compile and build MySQL from the source code provided by Oracle where you have the flexibility to customize build parameters, compiler optimizations, and the installation location. It is highly recommended to use precompiled binaries provided by Oracle, unless you want specific compiler options or you are debugging MySQL. 
    This method is not covered as it is used very rarely and it requires several development tools, which is beyond the scope of this book. For installation through source code, you can refer to the reference manual, at https://dev.mysql.com/doc/refman/8.0/en/source-installation.html.
  2. Using Docker. The MySQL server can also be installed and managed using Docker image. Refer to https://hub.docker.com/r/mysql/mysql-server/ for installation, configuration, and also how to use MySQL under Docker.

Starting or Stopping MySQL 8

After the installation is completed, you can start/stop MySQL using the following commands, which vary from different platforms and installation methods. mysqld is the mysql server process. All the startup methods invoke the mysqld script.

How to do it...

Let's look at it in detail. Along with the starting and stopping, we will also learn something about checking the status of the server. Let's see how.

Starting the MySQL 8.0 server

You can start the server with the following commands:

  1. Using service:
shell> sudo service mysql start
  1. Using init.d:
shell> sudo /etc/init.d/mysql start
  1. If you do not find the startup script (when you are doing binary installation), you can copy from the location where you untarred.
shell> sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  1. If your installation includes systemd support:
shell> sudo systemctl start mysqld
  1. If the systemd support is not there, MySQL can be started using mysqld_safe. mysqld_safe is the launcher script for mysqld that safeguards the mysqld process. If mysqld is killed, mysqld_safe attempts to start the process again:
shell> sudo mysqld_safe --user=mysql &

After start,

  1. The server is initialized.
  2. The SSL certificate and key files are generated in the data directory.
  3. The validate_password plugin is installed and enabled.
  4. A superuser account, root'@'localhost, is created. A password for the superuser is set and stored in the error log file (not for binary installation). To reveal it, use the following command:
shell> sudo  grep "temporary password" /var/log/mysqld.log 
2017-12-02T07:23:20.915827Z 5 [Note] A temporary password is generated for root@localhost: bkvotsG:h6jD

You can connect to MySQL using that temporary password.

shell> mysql -u root -pbkvotsG:h6jD
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.3-rc-log

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>
  1. Change the root password as soon as possible by logging in with the generated temporary password and setting a custom password for the superuser account:
# You will be prompted for a password, enter the one you got from the previous step

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPass4!';
Query OK, 0 rows affected (0.01 sec)

# password should contain at least one Upper case letter, one lowercase letter, one digit, and one special character, and that the total password length is at least 8 characters

Stopping the MySQL 8.0 server

Stopping MySQL and checking the status are similar to starting it, except for the change of one word:

  1. Using service:
shell> sudo service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
  1. Using init.d:
shell> sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
  1. If your installation includes the systemd support (refer to the Managing MySQL Server with systemd section):
shell> sudo systemctl stop mysqld
  1. Using mysqladmin:
shell> mysqladmin -u root -p shutdown

Checking the status of the MySQL 8.0 server

  1. Using service:
shell> sudo systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mysqld.service.d
└─override.conf
Active: active (running) since Sat 2017-12-02 07:33:53 UTC; 14s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 10472 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 10451 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 10477 (mysqld)
CGroup: /system.slice/mysqld.service
└─10477 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid --general_log=1

Dec 02 07:33:51 centos7 systemd[1]: Starting MySQL Server...
Dec 02 07:33:53 centos7 systemd[1]: Started MySQL Server.
  1. Using init.d:
shell> sudo /etc/init.d/mysql status
● mysql.service - LSB: start and stop MySQL
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)

Dec 02 06:01:00 ubuntu systemd[1]: Starting LSB: start and stop MySQL...
Dec 02 06:01:00 ubuntu mysql[20334]: Starting MySQL
Dec 02 06:01:00 ubuntu mysql[20334]: *
Dec 02 06:01:00 ubuntu systemd[1]: Started LSB: start and stop MySQL.
Dec 02 06:01:00 ubuntu mysql[20334]: 2017-12-02T06:01:00.969284Z mysqld_safe A mysqld process already exists
Dec 02 06:01:55 ubuntu systemd[1]: Stopping LSB: start and stop MySQL...
Dec 02 06:01:55 ubuntu mysql[20445]: Shutting down MySQL
Dec 02 06:01:57 ubuntu mysql[20445]: .. *
Dec 02 06:01:57 ubuntu systemd[1]: Stopped LSB: start and stop MySQL.
Dec 02 07:26:33 ubuntu systemd[1]: Stopped LSB: start and stop MySQL.
  1. If your installation includes the systemd support (refer to the Managing MySQL Server with systemd section):
shell> sudo systemctl status mysqld

Uninstalling MySQL 8

If you have messed up with installation or you do not want MySQL 8 version, you can uninstall using the following steps. Before uninstalling, make sure to make backup files (refer to Chapter 7, Backups), if required, and stop MySQL.

How to do it...

Uninstalling will be dealt in a different way on different systems. Let's look at how.

On YUM-based systems

  1. Check whether there are any existing packages:
shell> rpm -qa | grep -i mysql-community
mysql-community-libs-8.0.3-0.1.rc.el7.x86_64
mysql-community-common-8.0.3-0.1.rc.el7.x86_64
mysql-community-client-8.0.3-0.1.rc.el7.x86_64
mysql-community-libs-compat-8.0.3-0.1.rc.el7.x86_64
mysql-community-server-8.0.3-0.1.rc.el7.x86_64
  1. Remove the packages. You may be notified that there are other packages dependent on MySQL. If you plan on installing MySQL again, you can ignore the warning by passing the --nodeps option:
shell> rpm -e <package-name>

For example:

shell> sudo rpm -e mysql-community-server
  1. To remove all packages:
shell> sudo rpm -qa | grep -i mysql-community | xargs sudo rpm -e --nodeps
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

On APT-based systems

  1. Check whether there are any existing packages:
shell> dpkg -l | grep -i mysql
  1. Remove the packages using the following:
shell> sudo apt-get remove mysql-community-server mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core mysql-server
0 upgraded, 0 newly installed, 7 to remove and 341 not upgraded.
After this operation, 357 MB disk space will be freed.
(Reading database ... 134358 files and directories currently installed.)
Removing mysql-server (8.0.3-rc-1ubuntu16.04) ...
Removing mysql-community-server (8.0.3-rc-1ubuntu16.04) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Removing mysql-client (8.0.3-rc-1ubuntu16.04) ...
Removing mysql-community-client (8.0.3-rc-1ubuntu16.04) ...
Removing mysql-common (8.0.3-rc-1ubuntu16.04) ...
Removing mysql-community-client-core (8.0.3-rc-1ubuntu16.04) ...
Removing mysql-community-server-core (8.0.3-rc-1ubuntu16.04) ...
Processing triggers for man-db (2.7.5-1) ...

Or remove them using:

shell> sudo apt-get remove --purge mysql-\* -y
shell> sudo apt-get autoremove -y
  1. Verify that the packages are uninstalled:
shell> dpkg -l | grep -i mysql
ii mysql-apt-config 0.8.9-1 all Auto configuration for MySQL APT Repo.
rc mysql-common 8.0.3-rc-1ubuntu16.04 amd64 MySQL Common
rc mysql-community-client 8.0.3-rc-1ubuntu16.04 amd64 MySQL Client
rc mysql-community-server 8.0.3-rc-1ubuntu16.04 amd64 MySQL Server

rc indicates that the packages have been removed (r), and only config files (c) have been kept.

Uninstalling Binaries

It is very simple to uninstall a binary installation. All you need to do is to remove the symlink:

  1. Change the directory to the installation path:
shell> cd /usr/local
  1. Check where mysql is pointing to, which will show the path it is referencing to:
shell> sudo ls -lh mysql
  1. Remove mysql:
shell> sudo rm mysql
  1. Remove the binaries (optional):
shell> sudo rm -f /opt/mysql-8.0.3-rc-linux-glibc2.12-x86_64.tar.gz

Managing the MySQL Server with systemd

If you install MySQL using an RPM or Debian package server, startup and shutdown is managed by systemd. On platforms for which the systemd support for MySQL is installed, mysqld_safe, mysqld_multi, and mysqld_multi.server are not installed. MySQL server startup and shutdown is managed by systemd using the systemctl command. You need to configure systemd as follows.

RPM-based systems use the mysqld.service files, and APT-based systems use the mysql.server files.

How to do it...

  1. Create a localized systemd configuration file:
shell> sudo mkdir -pv /etc/systemd/system/mysqld.service.d
  1. Create/open the conf file:
shell> sudo vi /etc/systemd/system/mysqld.service.d/override.conf
  1. Enter the following:
[Service]
LimitNOFILE=max_open_files (ex: 102400)
PIDFile=/path/to/pid/file (ex: /var/lib/mysql/mysql.pid)
Nice=nice_level (ex: -10)
Environment="LD_PRELOAD=/path/to/malloc/library" Environment="TZ=time_zone_setting"
  1. Reload systemd:
shell> sudo systemctl daemon-reload
  1. For temporary changes, you can reload without editing the conf file:
shell> sudo systemctl set-environment MYSQLD_OPTS="--general_log=1"
or unset using
shell> sudo systemctl unset-environment MYSQLD_OPTS
  1. After modifying the systemd environment, restart the server to make the changes effective.
    Enable mysql.serviceshell> sudo systemctl, and enable mysql.service:
shell> sudo systemctl unmask mysql.service
  1. Restart mysql:
    On RPM platforms:
shell> sudo systemctl restart mysqld

On Debian platforms:

shell> sudo systemctl restart mysql

Downgrading from MySQL 8.0

If your application is not performing as expected, you can always downgrade to a previous GA release (MySQL 5.7). Before downgrading, it is recommended to take a logical backup (refer to Chapter 7, Backups). Note that you can downgrade by only one previous release. Suppose that you want to downgrade from MySQL 8.0 to MySQL 5.6, you have to downgrade to MySQL 5.7, and then from MySQL 5.7 to MySQL 5.6.

You can do it in two ways:

  • In-place downgrade (downgrades within MySQL 8)
  • Logical downgrade

How to do it...

In the following subsections, you will be learning how to handle the installation/uninstallation/upgrade/downgrade using various repositories, bundles, and so on.

In-place Downgrades

For downgrades between the GA status releases within MySQL 8.0 (note that you cannot downgrade to MySQL 5.7 using this method):

  1. Shut down the old MySQL version
  2. Replace the MySQL 8.0 binaries or older binaries
  3. Restart MySQL on the existing data directory
  4. Run the mysql_upgrade utility

Using YUM repositories

  1. Prepare MySQL for a slow shutdown, which ensures that the undo logs are empty and data files are fully prepared in case of file format differences between releases:
mysql> SET GLOBAL innodb_fast_shutdown = 0;
  1. Shut down the mysql server as described in the Stopping MySQL 8.0 Server section:
shell> sudo systemctl stop mysqld
  1. Remove the InnoDB redo log files (the ib_logfile* files) from the data directory to avoid downgrade issues related to redo log file format changes that may have occurred between releases:
shell> sudo rm -rf /var/lib/mysql/ib_logfile*
  1. Downgrade MySQL. To downgrade the server, you need to uninstall MySQL 8.0, as described in the Uninstalling MySQL 8 section. The configuration files are automatically stored as backup.

    List the available versions:
shell> sudo yum list mysql-community-server

Downgrades are tricky; it is better to remove the existing packages before downgrading:

shell> sudo rpm -qa | grep -i mysql-community | xargs sudo rpm -e --nodeps
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

Install the older version:

shell> sudo yum install -y mysql-community-server-<version>

Using APT Repositories

  1. Reconfigure MySQL and choose the older version:
shell> sudo dpkg-reconfigure mysql-apt-config
  1. Run apt-get update:
shell> sudo apt-get update
  1. Remove the current version:
shell> sudo apt-get remove mysql-community-server mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core -y

shell> sudo apt-get autoremove
  1. Install the older version (autoselected since you have reconfigured):
shell> sudo apt-get install -y mysql-server

Using the RPM or APT bundle

Uninstall the existing packages (refer to the Uninstalling MySQL 8 section) and install the new packages, which can be downloaded from the MySQL Downloads (refer to the Installing MySQL 8.0 using RPMs or DEB files section).

Using Generic Binaries

If you have installed MySQL through binaries, you have to remove the symlink to the old version (refer to the Uninstalling MySQL 8 section) and do a fresh installation (refer to the Installing MySQL on Linux Using Generic Binaries section):

  1. Start the server as described in the Starting or Stopping MySQL 8 section. Please note that the start procedure is the same for all the versions.
  2. Run the mysql_upgrade utility:
shell> sudo mysql_upgrade -u root -p
  1. Restart the MySQL server to ensure that any changes made to the system tables take effect:
shell> sudo systemctl restart mysqld

Logical Downgrades

Here is an outline of the steps:

  1. Export existing data from the MySQL 8.0 version using logical backup (refer to Chapter 7, Backups for logical backup methods)
  2. Install MySQL 5.7
  3. Load the dump file into the MySQL 5.7 version (refer to Chapter 8, Restoring Data for restoring methods)
  4. Run the mysql_upgrade utility

Here are the detailed steps:

  1. You need to take logical backup of the database. (refer to Chapter 7, Backups for a quicker backup called mydumper):
shell> mysqldump -u root -p --add-drop-table --routines --events --all-databases --force > mysql80.sql
  1. Shut down the MySQL server as described in the Starting or Stopping MySQL 8 section.
  2. Move the data directory. Instead of restoring the SQL backup (in step 1), we can move back the data directory if you want to keep MySQL 8:
shell> sudo mv /var/lib/mysql /var/lib/mysql80
  1. Downgrade MySQL. To downgrade the server, we need to uninstall MySQL 8. The configuration files are automatically backed up.

Using YUM Repositories

After the uninstallation, install the older version:

  1. Switch the repositories:
shell> sudo yum-config-manager --disable mysql80-community
shell> sudo yum-config-manager --enable mysql57-community
  1. Verify that mysql57-community is enabled:
shell> yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64 MySQL Connectors Community 42
!mysql-tools-community/x86_64 MySQL Tools Community 53
!mysql57-community/x86_64 MySQL 5.7 Community Server 227
  1. Downgrades are tricky; it is better to remove the existing packages before downgrading:
shell> sudo rpm -qa | grep -i mysql-community | xargs sudo rpm -e --nodeps
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
  1. List the available versions:
shell> sudo yum list mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.rackspace.com
* epel: mirrors.develooper.com
* extras: centos.s.uw.edu
* updates: mirrors.syringanetworks.net
Available Packages
mysql-community-server.x86_64 5.7.20-1.el7 mysql57-community
  1. Install MySQL 5.7:
shell> sudo yum install -y mysql-community-server

Using APT Repositories

  1. Reconfigure apt to switch to MySQL 5.7:
shell> sudo dpkg-reconfigure mysql-apt-config
  1. Run apt-get update:
shell> sudo apt-get update
  1. Remove the current version:
shell> sudo apt-get remove mysql-community-server mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core -y
shell> sudo apt-get autoremove
  1. Install MySQL 5.7:
shell> sudo apt-get install -y mysql-server

Using RPM or APT bundles

Uninstall the existing packages (refer to the Uninstalling MySQL 8 section) and install the new packages, which can be downloaded from MySQL Downloads (refer to the Installing MySQL 8 using RPM or DEB files section).

Using Generic Binaries

If you have installed MySQL through binaries, you have to remove the symlink to the old version (refer to the Uninstalling MySQL 8 section) and do a fresh installation (refer to the Installing MySQL on Linux using Generic Binaries section).

Once you have downgraded MySQL, you have to restore the backup and run the mysql_upgrade utility:

  1. Start MySQL (refer to the Starting or Stopping MySQL 8 section). You need to reset the password again.
  2. Restore the backup (this may take a long time, depending up on the size of backup). Refer to Chapter 8, Restoring Data, for a quick restoration method called myloader:
shell> mysql -u root -p < mysql80.sql
  1. Run mysql_upgrade:
shell> mysql_upgrade -u root -p
  1. Restart the MySQL server to ensure that any changes made to the system tables take effect. Refer to the Starting or Stopping MySQL 8 section:
shell> sudo /etc/init.d/mysql restart

Upgrading to MySQL 8.0

MySQL 8 uses a global data dictionary containing information about database objects in transactional tables. In previous versions, the dictionary data was stored in metadata files and non-transactional system tables. You need to upgrade your data directory  from the file-based structure to the data-dictionary structure.

Just like a downgrade, you can upgrade using two methods:

  • In-place upgrade
  • Logical upgrade

You also should check a few prerequisites before the upgrade.

Getting ready

  1. Check for obsolete datatypes or triggers that have a missing or empty definer or an invalid creation context:
shell> sudo mysqlcheck -u root -p --all-databases --check-upgrade
  1. There must be no partitioned tables that use a storage engine that does not have native partitioning support. To identify these tables, execute this query:
shell> SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE ENGINE NOT IN ('innodb', 'ndbcluster') AND CREATE_OPTIONS LIKE '%partitioned%';

If there are any of these tables, change them to InnoDB:

mysql> ALTER TABLE table_name ENGINE = INNODB;

Or remove the partitioning:

mysql> ALTER TABLE table_name REMOVE PARTITIONING;
  1. There must be no tables in the MySQL 5.7 mysql system database that have the same name as a table used by the MySQL 8.0 data dictionary. To identify tables with those names, execute this query:
mysql> SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE LOWER(TABLE_SCHEMA) = 'mysql' and LOWER(TABLE_NAME) IN ('catalogs', 'character_sets', 'collations', 'column_type_elements', 'columns', 'events', 'foreign_key_column_usage', 'foreign_keys', 'index_column_usage', 'index_partitions', 'index_stats', 'indexes', 'parameter_type_elements', 'parameters', 'routines', 'schemata', 'st_spatial_reference_systems', 'table_partition_values', 'table_partitions', 'table_stats', 'tables', 'tablespace_files', 'tablespaces', 'triggers', 'version', 'view_routine_usage', 'view_table_usage');
  1. There must be no tables that have foreign key constraint names longer than 64 characters. To identify tables with constraint names that are too long, execute this query:
mysql> SELECT CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE LENGTH(CONSTRAINT_NAME) > 64;
  1. Tables not supported by MySQL 8.0, such as ndb, should be moved to InnoDB:
mysql> ALTER TABLE tablename ENGINE=InnoDB;

How to do it...

Just like the previous recipe, the following subsections will take you through the details with various systems, bundles, and so on. 

In-place upgrades

Here is an outline of the steps:

  1. Shut down the old MySQL version.
  2. Replace the old MySQL binaries or packages with the new ones (detailed steps for different types of installation methods are covered).
  3. Restart MySQL on the existing data directory.
  4. Run the mysql_upgrade utility.
  5. In the MySQL 5.7 server, if there are encrypted InnoDB tablespaces, rotate the keyring master key by executing this statement:
mysql> ALTER INSTANCE ROTATE INNODB MASTER KEY;

Here are the detailed steps:

  1. Configure your MySQL 5.7 server to perform a slow shutdown. With a slow shutdown, InnoDB performs a full purge and change buffer merge before shutting down, which ensures that the undo logs are empty and the data files are fully prepared in case of file format differences between releases.
    This step is the most important because, without it, you will end up with the following error:
[ERROR] InnoDB: Upgrade after a crash is not supported. 

This redo log was created with MySQL 5.7.18. Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/upgrading.html:

mysql> SET GLOBAL innodb_fast_shutdown = 0;
  1. Shut down the MySQL server as described in the Starting or Stopping MySQL 8 section.

Upgrade the MySQL binaries or packages.

YUM-based systems

  1. Switch the repositories:
shell> sudo yum-config-manager --disable mysql57-community
shell> sudo yum-config-manager --enable mysql80-community
  1. Verify that mysql80-community is enabled:
shell> sudo yum repolist all | grep mysql8
mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 16
mysql80-community-source MySQL 8.0 Community Server disabled
  1. Run the yum update:
shell> sudo yum update mysql-server

APT-based systems

  1. Reconfigure the apt to switch to MySQl 8.0:
shell> sudo dpkg-reconfigure mysql-apt-config
  1. Run apt-get update:
shell> sudo apt-get update
  1. Remove the current version:
shell> sudo apt-get remove mysql-community-server mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core -y
shell> sudo apt-get autoremove
  1. Install MySQL 8:
shell> sudo apt-get update
shell> sudo apt-get install mysql-server
shell> sudo apt-get install libmysqlclient21

Using RPM or APT bundles

Uninstall the existing packages (refer to the Uninstalling MySQL 8 section) and install the new packages, which can be downloaded from MySQL Downloads (refer to the Installing MySQL 8.0 using RPM or DEB files section).

Using Generic Binaries

If you have installed MySQL through binaries, you have to remove the symlink to the old version (refer to the Uninstalling MySQL 8 section) and do a fresh installation (refer to the Installing MySQL on Linux using generic binaries section).

Start the MySQL 8.0 server (refer to the Starting or Stopping MySQL 8 to start MySQL section). If there are encrypted InnoDB tablespaces, use the --early-plugin-load option to load the keyring plugin.

The server automatically detects whether data dictionary tables are present. If not, the server creates them in the data directory , populates them with metadata, and then proceeds with its normal startup sequence. During this process, the server upgrades metadata for all database objects, including databases, tablespaces, system and user tables, views, and stored programs (stored procedures and functions, triggers, event scheduler events). The server also removes files that previously were used for metadata storage. For example, after upgrading, you will notice that your tables no longer have .frm files.

The server creates a directory named backup_metadata_57 and moves the files used by MySQL 5.7 into it. The server renames the event and proc tables to event_backup_57 and proc_backup_57. If this upgrade fails, the server reverts all changes to the data directory. In this case, you should remove all redo log files, start your MySQL 5.7 server on the same data directory, and fix the cause of any errors. Then, perform another slow shutdown of the 5.7 server and start the MySQL 8.0 server to try again.

Run the mysql_upgrade utility:

shell> sudo mysql_upgrade -u root -p

mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL. It makes any remaining changes required in the mysql system database between MySQL 5.7 and MySQL 8.0, so that you can take advantage of new privileges or capabilities. mysql_upgrade also brings the performance schema, INFORMATION_SCHEMA, and sys schema objects up to date for MySQL 8.0.

Restart the MySQL server (refer to the Starting or Stopping MySQL 8 to start MySQL section).

Logical Upgrades

Here is an outline of the steps:

  1. Export existing data from the old MySQL version using mysqldump
  2. Install the new MySQL version
  3. Load the dump file into the new MySQL version
  4. Run the mysql_upgrade utility

Here are the detailed steps:

  1. You need to take a logical backup of the database (refer to Chapter 7, Backups for a quicker backup called mydumper):
shell> mysqldump -u root -p --add-drop-table --routines --events --all-databases --ignore-table=mysql.innodb_table_stats --ignore-table=mysql.innodb_index_stats --force > data-for-upgrade.sql
  1. Shut down the MySQL server (refer to the Starting or Stopping MySQL 8 section).
  2. Install the new MySQL version (refer to the methods mentioned in the In-place upgrades section).
  3. Start the MySQL server (refer to the Starting or Stopping MySQL 8 section).
  4. Reset the temporary root password:
shell> mysql -u root -p
Enter password: **** (enter temporary root password from error log)

mysql> ALTER USER USER() IDENTIFIED BY 'your new password';
  1. Restore the backup (this may take a long time depending up on the size of the backup). Refer to Chapter 8, Restoring Data for a quick restoration method called myloader:
shell> mysql -u root -p --force < data-for-upgrade.sql
  1. Run the mysql_upgrade utility:
shell> sudo mysql_upgrade -u root -p
  1. Restart the MySQL server (refer to the Starting or Stopping MySQL 8 section).

Installing MySQL utilities

MySQL utilities gives you very handy tools to smoothly carry out day-to-day operations without much manual effort.

How to do it...

It can be installed on YUM-based and APT-based systems in the following manner. Let's take a look.

On YUM-based systems

Download the files from the MySQL downloads page, https://dev.mysql.com/downloads/utilities/, by selecting Red Hat Enterprise Linux/Oracle Linux, or directly from this link, using wget:

shell> wget https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-utilities-1.6.5-1.el7.noarch.rpm

shell> sudo yum localinstall -y mysql-utilities-1.6.5-1.el7.noarch.rpm

On APT-based systems

Download the files from the MySQL Downloads page, https://dev.mysql.com/downloads/utilities/, by selecting Ubuntu Linux,  or directly from this link, using wget:

shell> wget "https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-utilities_1.6.5-1ubuntu16.10_all.deb"
shell> sudo dpkg -i mysql-utilities_1.6.5-1ubuntu16.10_all.deb
shell> sudo apt-get install -f

Left arrow icon Right arrow icon

Key benefits

  • Store, retrieve, and manipulate your data using the latest MySQL 8 features
  • Practical recipes on effective administration in MySQL, with a focus on security, performance tuning, troubleshooting, and more
  • Contains tips, tricks, and best practices for designing, developing, and administering your MySQL 8 database solution without any hassle

Description

MySQL is one of the most popular and widely used relational databases in the World today. The recently released MySQL 8 version promises to be better and more efficient than ever before. This book contains everything you need to know to be the go-to person in your organization when it comes to MySQL. Starting with a quick installation and configuration of your MySQL instance, the book quickly jumps into the querying aspects of MySQL. It shows you the newest improvements in MySQL 8 and gives you hands-on experience in managing high-transaction and real-time datasets. If you've already worked with MySQL before and are looking to migrate your application to MySQL 8, this book will also show you how to do that. The book also contains recipes on efficient MySQL administration, with tips on effective user management, data recovery, security, database monitoring, performance tuning, troubleshooting, and more. With quick solutions to common and not-so-common problems you might encounter while working with MySQL 8, the book contains practical tips and tricks to give you the edge over others in designing, developing, and administering your database effectively.

Who is this book for?

If you are a MySQL developer or administrator looking for quick, handy solutions to solve the most common and not-so-common problems in MySQL, this book is for you. MySQL DBAs looking to get up-to-speed with the latest MySQL 8 development and administration features will also find this book very useful. Prior knowledge of Linux and RDBMS is desirable.

What you will learn

  • Install and configure your MySQL 8 instance without any hassle
  • Get to grips with new features of MySQL 8 like CTE, Window functions and many more
  • Perform backup tasks, recover data and set up various replication topologies for your database
  • Maximize performance by using new features of MySQL 8 like descending indexes, controlling query optimizer and resource groups
  • Learn how to use general table space to suit the SaaS or multi-tenant applications
  • Analyze slow queries using performance schema, sys schema and third party tools
  • Manage and monitor your MySQL instance and implement efficient performance-tuning tasks
Estimated delivery fee Deliver to Canada

Economy delivery 10 - 13 business days

Can$24.95

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 25, 2018
Length: 446 pages
Edition : 1st
Language : English
ISBN-13 : 9781788395809
Category :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Canada

Economy delivery 10 - 13 business days

Can$24.95

Product Details

Publication date : Jan 25, 2018
Length: 446 pages
Edition : 1st
Language : English
ISBN-13 : 9781788395809
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Can$ 181.97
MySQL 8 Administrator???s Guide
Can$55.99
Mastering PostgreSQL 10
Can$55.99
MySQL 8 Cookbook
Can$69.99
Total Can$ 181.97 Stars icon
Banner background image

Table of Contents

14 Chapters
MySQL 8 - Installing and Upgrading Chevron down icon Chevron up icon
Using MySQL Chevron down icon Chevron up icon
Using MySQL (Advanced) Chevron down icon Chevron up icon
Configuring MySQL Chevron down icon Chevron up icon
Transactions Chevron down icon Chevron up icon
Binary Logging Chevron down icon Chevron up icon
Backups Chevron down icon Chevron up icon
Restoring Data Chevron down icon Chevron up icon
Replication Chevron down icon Chevron up icon
Table Maintenance Chevron down icon Chevron up icon
Managing Tablespace Chevron down icon Chevron up icon
Managing Logs Chevron down icon Chevron up icon
Performance Tuning Chevron down icon Chevron up icon
Security Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(4 Ratings)
5 star 25%
4 star 50%
3 star 0%
2 star 0%
1 star 25%
K. Sai Kiran Jul 26, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really liked the performance tuning chapter. Apt data sets and queries are shown to illustrate the optimizations.
Amazon Verified review Amazon
Omega Jan 08, 2019
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
a great book as a handy reference.
Amazon Verified review Amazon
Bo Green Oct 30, 2019
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
would like to see more valueable content
Amazon Verified review Amazon
c shah Nov 17, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
I have purchased kindle version of this book. It is pathetic. The formatting of the chapter is not readable.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela