Install MySQL 8.0 in Linux and Windows

MySQL community server is a free open source, popular and cross-platform database management system. It supports both SQL and NoSQL, and has a pluggable storage engine architecture. Additionally, it also comes with multiple database connectors for different programming languages, allowing you to develop applications using any of the well known languages, and many other features.MySQL_8.0

MySQL Server is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.It has many use cases under document storage, cloud, high availability systems, IoT (Internet of Things), hadoop, big data, data warehousing, LAMP or LEMP stack for supporting high-volume website/apps and much more.

The MySQL software is Dual Licensed. Users can choose to use the MySQL software as an Open Source product under the terms of the GNU General Public License or can purchase a standard commercial license from Oracle.

In this article, we will explain a fresh installation of community MySQL 8.0 database system on different Linux environments and Windows.

What’s New in MySQL 8.0

https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html

Installing MySQL on Linux Using the MySQL Yum Repository

  • Download and install the latest yum release package for your platform from yum repository page  ( Redhat 7, CentOS 7, Linux AMI, Fedora)
$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
$ rpm -ivh mysql80-community-release-el7-3.noarch.rpm

For fedora

sudo dnf localinstall mysql80-community-release-el7-3.noarch.rpm

Check that the MySQL Yum repository has been successfully added by the following command

yum repolist enabled | grep "mysql.*-community.*"

To install the latest release from a specific series other than the latest GA series, disable the sub repository for the latest GA series and enable the sub repository for the specific series before running the installation command.

$ sudo yum-config-manager --disable mysql57-community
$ sudo yum-config-manager --enable mysql80-community

We can also select a release series by editing manually the /etc/yum.repos.d/mysql-community.repo file. Find the entry for the subrepository you want to configure, and edit the enabled option. Specify enabled=0 to disable a subrepository, or enabled=1 to enable a sub repository.

  • Installing MySQL
$ sudo yum -y install mysql-community-server

This installs the package for MySQL server and all dependency packages.

  • Starting the MySQL Server
$ sudo service mysqld start
$ sudo service mysqld status
or
systemctl start  mysqld.service
  • Find the password of super user account (root) user
$ sudo grep 'temporary password' /var/log/mysqld.log
  • Securing MySQL installation

The command mysql_secure_installation allows you to secure your MySQL installation by performing important settings like setting the root password, removing anonymous users, removing root login etc.

$ /usr/bin/mysql_secure_installation

mysql1.JPG

Installing MySQL on Linux Using RPM Packages from Oracle

  • Download latest MySQL binary package from here 
# cd /home/ec2-user
# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
# tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar

Remove pre-installed mariadb libraries if any

yum -y remove mariadb-libs

Install the rpm packages

rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-test-8.0.16-2.el7.x86_64.rpm

If there are failed dependency packages, we can find the required binaries using yum provides command. Please find the example below

yum provides '*/libncurses.so.5'

Verify the packages installed

pic2

  • Start the MySQL instance
$ sudo service mysqld start
$ sudo service mysqld status
or
systemctl start  mysqld.service
  • Find the password of super user account (root) user
$ sudo grep 'temporary password' /var/log/mysqld.log

Installing MySQL on Unix/Linux Using Generic Binaries

This  installation has to be done under a privileged account (root):

shell> sudo yum install libaio
shell> apt-get install libaio1      # In APT based systems 
shell> sudo groupadd mysql
shell> sudo useradd -r -g mysql -s /bin/bash mysql
shell> sudo cp mysqld@.service /etc/systemd/system/

Installing the binaries :

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar xvf /path/to/mysql-VERSION-OS.tar.xz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

Installing MySQL on Linux Using the MySQL APT Repository

  • Download and install the latest yum release package for your platform from yum repository page (Ubuntu 16,17&18 and Debian)
$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb

Install the repository binaries

$ sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

Update package information from the MySQL APT repository with the following command

$ sudo apt-get update
  • Installing MySQL with APT
$ sudo apt-get install mysql-server
  • Start the MySQL instance
$ sudo service mysqld start
$ sudo service mysqld status
  • See the packages installed from MySQL apt repository
$ dpkg -l | grep mysql | grep ii

Installing MySQL on Linux Using Debian Packages from Oracle

  • Download latest MySQL binary package from here 
$ wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-server_8.0.16-2ubuntu18.04_i386.deb-bundle.tar

After downloading the tarball, unpack it with the following command:

$ tar -xvf mysql-server_8.0.16-2ubuntu18.04_i386.deb-bundle.tar

We need to install the libaio library if it is not already present on your system

$ sudo apt-get install libaio1

Preconfigure the MySQL server package

$ sudo dpkg-preconfigure mysql-community-server_*.deb

You will be asked to provide a password for the root user for your MySQL installation.

Install the Packages

$ sudo dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb

Installing MySQL on Solaris Using a Solaris PKG

To obtain a binary MySQL distribution for Solaris in tarball or PKG format, https://dev.mysql.com/downloads/mysql/8.0.html.

$ groupadd mysql
$ useradd -g mysql -s /bin/false mysql
$ gunzip mysql-8.0.18-solaris11-x86_64.pkg.gz

To install a new package, use pkgadd and follow the onscreen prompts

$ pkgadd -d mysql-8.0.18-solaris11-x86_64.pkg

By default, the PKG package installs MySQL under the root path /opt/mysql. You can change only the installation root path when using pkgadd, which can be used to install MySQL in a different Solaris zone. If you need to install in a specific directory, use a binary tar file distribution.

To enable MySQL to startup and shutdown automatically, you should create a link between this file and the init script directories.

$ ln /etc/init.d/mysql /etc/rc3.d/S91mysql
$ ln /etc/init.d/mysql /etc/rc0.d/K02mysql

MySQL Server Deployment with Docker

  • Downloading a MySQL Server Docker Image
$ docker pull mysql/mysql-server:tag

The tag is the label for the image version you want to pull (for example, 5.5, 5.6, 5.7, 8.0, or latest). If :tag is omitted, the latest label is used, and the image for the latest GA version of MySQL Community Server is downloaded.

List downloaded Docker images with this command:

$  docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
mysql/mysql-server   latest              3157d7f55f8d        4 weeks ago         241MB

To download the MySQL Enterprise Edition image from the My Oracle Support website, sign in to your Oracle account, download from Patches and Updates the tar.zip file for the Docker image (mysql-commercial-version_linux_x86_64_docker_tar.zip), unzip it to obtain the tarball inside (mysql-enterprise-server-version.tar), and then load the image by running this command:

$ docker load -i mysql-enterprise-server-version.tar
  • Starting a MySQL Server Instance
$ docker run --name=container_name -d image_name:tag
$ docker run --name=mysql1 -d mysql/mysql-server:8.0

For enterprise version

$ docker run --name=mysql1 -d mysql/enterprise-server:8.0

Container appears in the list of running containers when you run the docker ps command.

$ docker ps
CONTAINER ID   IMAGE                COMMAND                  CREATED             STATUS                              PORTS                NAMES
a24888f0d6f4   mysql/mysql-server   "/entrypoint.sh my..."   14 seconds ago      Up 13 seconds (health: starting)    3306/tcp, 33060/tcp  mysql1
  • Monitor logs
$ docker logs mysql1
  • Check the root password with following command
$ docker logs mysql1 2>&1 | grep GENERATED
GENERATED ROOT PASSWORD: xncvhrTyjsis0Kis&EShOs
  • Connecting to MySQL Server from within the Container
$ docker exec -it mysql1 mysql -uroot -p

We must reset the server root password by issuing this statement

mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
  • Container Shell Access
$ docker exec -it mysql1 bash
  • Stopping and Deleting a MySQL Container
$ docker stop mysql1
$ docker rm mysql1
  • Persisting Data and Configuration Changes
$ docker inspect mysql1

Installing MySQL on Microsoft Windows

MySQL Installer Method 

This package has a file name similar to mysql-installer-community-8.0.18.0.msi or mysql-installer-commercial-8.0.18.0.msi, and utilizes MSIs to automatically install MySQL server and other products. MySQL Installer will download and apply updates to itself, and for each of the installed products. It also configures the installed MySQL server (including a sandbox InnoDB cluster test setup) and MySQL Router. MySQL Installer is recommended for most users.

MySQL Installer is a standalone application designed to ease the complexity of installing and configuring MySQL products that run on Microsoft Windows. It supports the following MySQL products:

  • MySQL Servers
  • MySQL Applications :MySQL Workbench, MySQL Shell, MySQL Router, MySQL for Visual Studio, MySQL for Excel, MySQL Notifier, and MySQL Utilities.
  • MySQL Connectors : MySQL Connector/NET, MySQL Connector/Python, MySQL Connector/ODBC, MySQL Connector/J, MySQL Connector/C, and MySQL Connector/C++.

Download software from https://dev.mysql.com/downloads/installer/ to install the Community release of all MySQL products for Windows.

Prerequisites 

MySQL Installer requires Microsoft .NET Framework 4.5.2 or later.

Product Requirement 
MySQL Server 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64
MySQL WorkBench 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64
MySQL for Visual Studio 1.2.8 Visual Studio version  2012,2013,2015 or 2017
MySQL Shell 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64
MySQL Router 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64
Connector/ODBC 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64
Connector C++ 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64
Connector /Python (3.7) 8.0.16 Python 3.7 ( 64 bit)
Connector /Python (3.7) 8.0.16 Microsoft Visual C++ 2015 Redistribute Package x64

Choosing the right file:

  • If you have an online connection while running the MySQL Installer, choose the mysql-installer-web-community file.
  • If you do NOT have an online connection while running the MySQL Installer, choose the mysql-installer-community file.

In this example we will go with mysql-installer-community file

Double click on the downloaded mysql-installer-community-8.0.16.0 msi file

img9

Accept the GNU general public license and click next

mysql2.jpg

Choose the required setup type and click next

mysql3.jpg

Install the dependency packages required for installation. Click on execute to download packages from internet or download and install the packages manually.

mysql4.jpg

mysql5

Proceed with package installation , click Execute

mysql6.jpg

Once the installation completes click on next

mysql7

Proceed to product configuration

mysql8

Select the High Availability Options if required ( Standalone/Replication/Innodb Cluster)

mysql9.jpg

Choose the correct server configuration type and click next

mysql10.jpg

Choose the password encryption method and click next

mysql11

Choose the root password and create a user if required

mysql12

mysql13.jpg

Select the windows service name and define under which account MySQL needs to run.

mysql14.jpg

Under logging option select the logs we want to activate and choose the desired path

mysql15.jpg

Under Advanced option select the server id

mysql16.jpg

Click Execute to apply the configuration changes

mysql17.jpg

mysql18

Click Finish to exit the installation wizard

mysql19.jpg

For Innodb Cluster we need to configure router information.After configuration click finish

mysql20.jpg

Check the Server connectivity

mysql21.jpg

Click execute to apply the changes and once applied click finish.

mysql22.jpg

In final Installation complete tab we can copy the logs for future reference and click finish

mysql23.jpg

  • Connect to MySQL Server using Workbench 

Open Workbench from start menu

mysql24.jpg

Click on local instance and enter password for root user and click ok

mysql35.jpg

mysql26.jpg

Click on Server status to see the server health

mysql27.jpg

To see the processlist click on client connections

mysql28.jpg

SQL Editor

mysql29.jpg

  • Connect to MySQL Server using MySQL shell 8.0

Open MySQL shell in path C:\Program Files\MySQL\MySQL Shell 8.0\bin\mysqlsh

mysql30.jpg

Reference :

https://dev.mysql.com/doc/refman/8.0/en/installing.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: