MySQL binary installation This method does not involve compiling the MySQL source code, making it a faster and more straightforward way to set up a MySQL database system. Users typically download the appropriate binary distribution for their platform, extract it, configure MySQL, and then initialize and secure the database to make it ready for use.

STEP1: Update Package Repositories and Remove MariaDB These commands update the package repositories and remove any existing MariaDB installations.

yum update -y
yum remove mariadb*

STEP2: Create a MySQL User Create a user named “mysql” and set a password for this user. This user will be used to run the MySQL server for security reasons.

useradd mysql
passwd mysql

STEP3: Install wget Install the wget tool, which will be used to download the MySQL binary tarball

yum install wget

STEP4: Download MySQL Binary

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
tar xvf mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz

Download the MySQL binary tarball and extract its contents

STEP5: Move MySQL Files Move the extracted MySQL files to the /usr/local/mysql directory.

cd /usr/local/
sudo mv mysql-8.0.31-linux-glibc2.12-x86_64 /usr/local/mysql

STEP6: Install libaio

sudo yum install libaio

Install the libaio library, which MySQL requires.

STEP7: Configure MySQL

cd /usr/local/mysql/support-files
vi /etc/my.cnf

Edit the MySQL configuration file /etc/my.cnf with the following content

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
user=mysql

STEP8: Initialize MySQL Data Directory

sudo /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

Initialize the MySQL data directory

STEP9: Start MySQL Server

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

Start the MySQL server in the background.

STEP10: Set Permissions for MySQL Data Directory

chown -R mysql:mysql /usr/local/mysql/data

Ensure that the MySQL user has proper permissions for the data directory.

STEP11: Secure MySQL Installation

sudo /usr/local/mysql/bin/mysql_secure_installation

Run the MySQL secure installation script to set a root password and configure security options

STEP12: Access MySQL

cd /usr/local/mysql/bin/
./mysql -uroot -p

Access the MySQL server using the root user with the password you set during the secure installation

OUTPUT

[root@ip-172-31-41-137 ~]# /usr/local/mysql/bin/mysql -uroot -pMeena@123
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 11
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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>
mysql>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql>

Leave a Reply

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