MySQL is one of the most popular open-source relational database management systems (RDBMS). In this comprehensive guide, we will walk you through the process of how to set up a MySQL database server on Oracle Linux. Oracle Linux is a great choice for running MySQL, as it provides a stable and secure environment, as well as excellent performance. Let’s dive in!
Table of Contents
- Installing MySQL
- Configuring MySQL
- Securing MySQL
- Managing MySQL Services
- Creating and Managing MySQL Databases
Before we begin, ensure that you have:
- Oracle Linux 7 or 8 is installed on your server.
- A user account with
- A stable internet connection.
How to Set Up a MySQL Database Server on Oracle Linux
First, let’s update the system packages and install any necessary dependencies:
sudo yum update -y sudo yum install -y wget
Next, download the MySQL Yum repository:
Install the repository using
sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
Now, install MySQL:
sudo yum install -y mysql-community-server
Once the installation is complete, start the MySQL service and enable it to start at boot:
sudo systemctl start mysqld sudo systemctl enable mysqld
After installing MySQL, you must configure it for optimal performance and security. First, let’s retrieve the default
sudo grep 'temporary password' /var/log/mysqld.log
Take note of the password, as you’ll need it to log in to MySQL in the next step. Now, log in to MySQL:
mysql -u root -p
Enter the temporary password when prompted. Once logged in, change the
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewSecurePassword';
NewSecurePassword with a strong password of your choice.
Next, run the MySQL security script to secure your installation further:
This script will prompt you to:
- Change the
rootpassword (you can skip this since you’ve already done it)
- Remove anonymous users
- Disallow remote
- Remove the test database and access to it
- Reload privilege tables
Follow the prompts and answer accordingly to enhance the security of your MySQL installation.
Managing MySQL Services
To ensure that your MySQL server is running smoothly, it’s essential to know how to manage its services. Here are some basic commands:
sudo systemctl start mysqld
sudo systemctl stop mysqld
sudo systemctl restart mysqld
Check MySQL status:
sudo systemctl status mysqld
These commands will help you maintain control over your MySQL server and troubleshoot any issues that may arise.
Creating and Managing MySQL Databases
Now that your MySQL server is set up, it’s time to create and manage databases. Log in to MySQL using your
mysql -u root -p
root password when prompted. To create a new database, run the following command, replacing
my_database with your desired database name:
CREATE DATABASE my_database;
View a list of all databases, execute:
To create a new user and grant them privileges on the newly created database, run the following commands, replacing
my_database with your desired values:
CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'my_password'; GRANT ALL PRIVILEGES ON my_database.* TO 'my_user'@'localhost'; FLUSH PRIVILEGES;
Now, your new user has full access to the specified database. To switch to a different database, use the
From here, you can create tables, insert data, and perform various operations within the selected database.
Congratulations! You’ve successfully set up a MySQL database server on Oracle Linux. With your new MySQL server, you can create and manage databases, users, and access privileges to support various applications and services.
To further enhance your Oracle Linux server, consider installing additional software such as NGINX, Apache, or Python. Additionally, explore our tutorials on how to set up RAID 1 in Ubuntu and how to install TensorFlow on Oracle Linux for more advanced configurations and optimizations.
We hope this guide has provided you with a solid foundation for setting up and managing a MySQL database server on Oracle Linux. Happy database administration!