• Home
  • DBA Scripts
    • Oracle Scripts
    • SQL Server Scripts
  • Knowledge Base
    • Oracle Database
    • MS SQL Server
    • MongoDB
    • MariaDB
  • Troubleshoot
    • Oracle Database Issues
    • SQL Server Issues
  • Interview Questions
    • AWS Interview Questions
    • Oracle DBA Interview Questions
    • SQL Server Interview Questions
  • Courses
    • Oracle Database
    • Oracle DBA L1
    • Oracle DBA L2
    • Oracle DBA L3
  • Home
  • DBA Scripts
    • Oracle Scripts
    • SQL Server Scripts
  • Knowledge Base
    • Oracle Database
    • MS SQL Server
    • MongoDB
    • MariaDB
  • Troubleshoot
    • Oracle Database Issues
    • SQL Server Issues
  • Interview Questions
    • AWS Interview Questions
    • Oracle DBA Interview Questions
    • SQL Server Interview Questions
  • Courses
    • Oracle Database
    • Oracle DBA L1
    • Oracle DBA L2
    • Oracle DBA L3
home/Knowledge Base/MySQL/Install MySQL in Linux / Ubuntu
Popular Search:Oracle, SQL Server, MongoDB

Install MySQL in Linux / Ubuntu

119 views 0 March 10, 2024 sandeep

How to Install MySQL in the Linux / Ubuntu operating system.

This installation is based on the scnerio where we are going to use tar file to install into non-default location on the ubuntu server.

**All the below steps are performed as the ROOT user

1. Install the necessary packages

apt-get update
apt-get install libncurses5-dev libncursesw5-dev libaio1 libncurses5

2. Create mysql user:

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

3. Create necessary directories as below using mkdir command.

base directory => mkdir -p /u01/mysql/base
data directory => mkdir -p /u01/mysql/data
log directory   => mkdir -p /u01/mysql/logs

4.  Download MySQL version 8.0.32 using the below wget command.

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz

untar the file in base directory /u01/mysql/base

tar -xvf mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz

– copy content of mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz to one directory back in base directory.

– Change owner ship of the directories created in Step 3 to mysql

chown -R mysql:mysql /u01/mysql

5. Create confirgurtaion file my.cnf under /etc

vi /etc/my.cnf

[mysqld]
basedir=/u01/mysql/base
datadir=/u01/mysql/data
log_error=/u01/mysql/logs/error.log
port=3306
socket=/u01/mysql/data/mysql.sock

– Change ownership to mysql

chown mysql:mysql /etc/my.cnf

6. Initialize the MySQL

cd /u01/mysql/base/bin

./mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql

Start the MySQL Services:

cd /u01/mysql/base/bin

./mysqld --defaults-file=/etc/my.cnf --user=mysql &

=> Create soft link to socket file in case not default location:

ln -s /u01/mysql/data/mysql.sock /tmp/mysql.sock

7. Login into the MySQL using the temporary password generated in below error log file and change the password.

log_error=/u01/mysql/logs/error.log

cd /u01/mysql/base/bin
./mysql -uroot -p

alter user root@localhost identified by 'root';
show databases;
Tags:MySQL

Was this helpful?

Yes  No
Related Articles
  • Configure Master Slave Replication in MySQL
  • Purge Old Logs in MySQL
  • Type of Logs in MySQL
  • Install and Remove Plugin into MySQL
  • MySQL user Management
  • Start and Stop MySQL using the systemctl
Leave A Comment Cancel reply

MySQL
  • Install MySQL in Linux / Ubuntu
  • Configure Master Slave Replication in MySQL
  • Purge Old Logs in MySQL
  • Type of Logs in MySQL
  • Install and Remove Plugin into MySQL
  • MySQL user Management
View All 6  
Popular Articles
  • Upgrade Oracle Database from 11.2.0.3 to 12.1.0.2
  • Upgrading MariaDB on Windows
  • Oracle DBA Basic Interview Questions Part A
  • Purging Oracle Sysaux Tablespace
  • Client – Server Architecture
KB Categories
  • Oracle Database
    • Oracle RAC
    • Oracle ASM
    • Oracle GoldenGate
    • Oracle Tuning
    • Oracle 11g Database
    • Oracle Database Upgrade
    • Oracle 12c Database
    • ALL KB Oracle
    • Oracle 18c Database
    • Oracle Standby Database
  • MongoDB
  • MS SQL Server
  • MySQL
  • Interview Questions
    • AWS Interview Questions
    • Oracle DBA Interview Questions
    • SQL Server Interview Questions
  • MariaDB
Database Organization

Database Organization (DB ORG) is knowledge base for DBA to learn and execute the fundamental of different databases under one website. DB ORG is a non-profit initiative. ORACLE, MS SQL Server, MongoDB, MariaDB, Couchbase

Join Our Community
  • KnowledgeBase
  • Documentation
  • Troubleshoot
  • FAQ
Information Links
  • About DBOrg
  • Licenses
  • Terms
  • Privacy Policy
Contact Us
    DB ORG - Database Administration,
    Knowledge Base for DBA
    Mail: support@databaseorg.com
    WhatsApp: (+91) 9306440957
    Monday to Friday: EST - 11:30 AM to 06:30 PM (IST - 9:00 PM to 4:00 AM)
  • © 2023 Database Organization - DB ORG. All Rights Reserved.

Popular Search:Oracle, SQL Server, MongoDB

WhatsApp DB Org