Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MySQL 8 Cookbook

You're reading from   MySQL 8 Cookbook Over 150 recipes for high-performance database querying and administration

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher
ISBN-13 9781788395809
Length 446 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Karthik Appigatla Karthik Appigatla
Author Profile Icon Karthik Appigatla
Karthik Appigatla
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. MySQL 8 - Installing and Upgrading 2. Using MySQL FREE CHAPTER 3. Using MySQL (Advanced) 4. Configuring MySQL 5. Transactions 6. Binary Logging 7. Backups 8. Restoring Data 9. Replication 10. Table Maintenance 11. Managing Tablespace 12. Managing Logs 13. Performance Tuning 14. Security

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.
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime