Set Up MySQL 8 from Binary Tarball

In this article, we’ll discuss binary tarball MySQL installation. We will discuss MySQL 8 installation using binary tarballs and install MySQL 8 on CentOS 7 using binary tarballs. Binary tarballs based installation has its own pros and cons, we will go through that. Installation from binary tarballs is independent of the Linux distribution or the init system the distribution uses. This means the same installation method works on RPM and dead based systems for example, but it will also work on more exotic distributions like Gen 2 as well. There is a binary tarball for macOS available too and the installation procedure is not much different, this method needs a more manual word. The mysql_install_db script was deprecated in MySQL 5.7 and is removed from MySQL 8. The initial database creation can be done with mysqld –initialize command. Now that we will install MySQL be manually we will use mysqld –initialize command to create an empty database.

First let’s do some cleanup. We will remove the very old version of mariadb-libs which provides my.cnf which would conflict with ours.

Remove Mariadb libs:

[root@localhost ~]# sudo yum remove -y mariadb-libs

Download the source tarball of MySQL community survey 8.0

[root@localhost ~]# curl -L -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 575M 100 575M 0 0 7726k 0 0:01:16 0:01:16 --:--:-- 8516k
[root@localhost ~]# ll
-rw-r--r--. 1 root root 603019898 Jul 23 10:31 mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz

The tarball is not downloaded so let’s unpack it to usr/local

[root@localhost ~]# sudo tar xvfz mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

Completing the pre-reqs

let’s install libaio.

[root@localhost ~]# sudo yum -y install libaio
Create a MySQL group, this is normally done by the packages but because we are installing it manually from binary tarball now we need to do it.
[root@localhost ~]# sudo groupadd mysql

Let’s create a MySQL user you

[root@localhost ~]# sudo useradd -r -g mysql -s /bin/false mysql

verify mysql user is there

[root@localhost ~]# getent passwd | grep mysql
mysql:x:988:1001::/home/mysql:/bin/false

got /usr/local and create a symlink and then check it

[root@localhost ~]# cd /usr/local
[root@localhost local]# sudo ln -s mysql-8.0.11-linux-glibc2.12-x86_64 mysql
[root@localhost local]# ls -la mysql
lrwxrwxrwx. 1 root root 35 Jul 23 15:08 mysql -> mysql-8.0.11-linux-glibc2.12-x86_64

create MySQL files directory which will hold the data set ownership and permissions while standing in /usr/local/

[root@localhost local]# sudo mkdir mysql-files
[root@localhost local]# sudo chown mysql:mysql mysql-files
[root@localhost local]# sudo chmod 750 mysql-files

Initialize MySQL

Go to mysql directory and Initialize mysqld, on earlier versions this was called mysql_installed_db

[root@localhost local]# cd mysql
[root@localhost mysql]# sudo ./bin/mysqld --initialize --user=mysql
2020-07-23T12:12:10.028247Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 25014
2020-07-23T12:12:15.470538Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Hqn+jK6lfzNS
2020-07-23T12:12:18.875370Z 0 [System] [MY-013170] [Server] /usr/local/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.11) initializing of server has completed

Note that the temporary root password is generated which in my case is (root@localhost: Hqn+jK6lfzNS)

Copy the init script from support-files to /etc/init.d

[root@localhost mysql]# sudo cp ./support-files/mysql.server /etc/init.d/

start mysql server with init file we just copied

[root@localhost mysql]# sudo /etc/init.d/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS!

Now connect ro mysql by providing the temporary passwd generated earlier

[root@localhost mysql]# ./bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11
Copyright (c) 2000, 2018, 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>

Let’s chenge the temporary passwd for the root user.

mysql> alter user 'root'@'localhost' identified by 'My_root_pass1!';
Query OK, 0 rows affected (0.07 sec)

Check socket file location:

mysql> show variables like 'socket';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| socket | /tmp/mysql.sock |
+---------------+-----------------+
1 row in set (0.01 sec)

To avoid having to type the path name of client programs always when you are working with MySQL, you can add the /usr/local/mysql/bin directory to your PATH variable:

[root@localhost mysql]# export PATH=$PATH:/usr/local/mysql/bin
[root@localhost mysql]# ps -ef | grep mysql
root 25130 1 0 15:16 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
mysql 25215 25130 1 15:16 pts/1 00:00:42 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
root 26171 21375 0 16:21 pts/1 00:00:00 mysql -uroot -px xxxxxxxxxxxx
root 26191 25365 0 16:23 pts/2 00:00:00 grep --color=auto mysq

About Mughees Ahmed

Over 2-year experience of Administration in Oracle, SQL Server, and MySQL databases using various tools and technologies. Keen on learning new database technologies having very good analytical skills. Working knowledge of Red Hat Linux, UNIX, Solaris and Windows Server 2012 is a valuable addition to my knowledge desk. KNOWLEDGE & SKILLS • Oracle Database Server 10g/11g/12c. • Oracle RAC, Data guard. • Oracle Golden Gate (Oracle to Oracle, Oracle to MySQL and MySQL to Oracle) • Oracle Enterprise Manager Grid Control, Toad, SQL developer. • SQL Server 2005/2008/2012/2016. • SQL Server Failover clustering, mirroring & log shipping, Always On availability groups. • MySQL 5 Administration, MySQL Workbench, MySQL Enterprise Monitor, SQLyog • MySQL NDB Cluster Installation,Administration. • MySQL Asynchronous/Semi-synchronous replication. • Oracle OEM Contact me on [email protected]

One comment

  1. Pingback: - IT Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *