Welcome back to shortlearner.com, in our previous post we learn How to Install PHP on CentOS.
now today in this post we will see how to install MySQL on CentOS.
before going to installation process we just take an overview of CentOS and MySQL.
CentOS is a Community Enterprise Operating System. It is an open-source platform for non-productive developmental work.
For production concern, those works can be migrated to RHEL (Red Hat Enterprise Linux) Linux distribution platform.
Also Read :
How to integrate Razorpay Payment Gateway using PHP.
Get Domain name from URL
How to Send Attachment on mail using PHP.
PHP Login Script With Remember me.
How to hide extension of html and php file.?
MySQL open-source tool and Database Management System. MySQL is a fast, stable, true multi-user, multi-threaded SQL database server.
Apart from the free edition, MySQL also offers other services like MySQL Enterprise Edition, MySQL Cluster CGE, Oracle MySQL Cloud Service and MySQL for OEM/ISV.
Drupal, Joomla, phpBB, and WordPress are some examples of MySQL database-driven web application.
Facebook, Flickr,MediaWiki, Twitter and YouTube are some examples of MySQL database–driven websites.
Install MySQL 8.0:
If you choose MySQL 8.0 for installation on CentOS 7. You can follow the below commands for installation.
First, We need to Enable the MySQL 8.0 Repository Package because MySQL 8.0 is not a default package in CentOS 7. Use the below command to enable for local installation
sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
Now the MySQL 8.0 Repository Package got enabled in the CentOS. We can directly install the package using below mentioned command.
sudo yum install mysql-community-server
don’t forgot to verify the signature key , it is the most important thing to do. For a specific package, we need to obtain a copy of public GPG build key. While installation it will be asked for key permission. so just type Y and hit the enter button.
sudo yum install mysql-community-server
After installation of MySQL:
1) Enabling the MySQL Service:
so the steps are mentioned below is same for any version of MySQL. so just follow the below steps one by one.
First , we need to enable mysqld . which will help to run the MySQL package in background during the boot time. Use below command for enabling the server.
sudo systemctl enable mysqld
after enabling the server we need to start the server for the connectivity by using the below command.
sudo systemctl start mysqld
now we need to check with the status of the server for its operating status. we can use below command to check the status in the output terminal – Status: SERVER_OPERATING
sudo systemctl status mysqld
2) Securing your Credentials:
For the first time when we start with our MySQL server, we will have default password in the MySQL server root user. we can locate the default password by using below command.
sudo grep 'temporary password' /var/log/mysqld.log
In the output our default password will be displayed. Remember the default password, will will help to login in further steps.
To enhance the security of the MySQL installation, use below command
When we execute the above command, it will be asked for a password. we need to enter our password there.
After this, we need to enter our own password.
For secure password: 8 Char length, 1 upper case, 1 lowercase, 1 special character, and 1 Numeric char.
Now the MySQL server will ask some questions regarding Access, User Permission, remove the database. so just type Y and hit the enter button for all questions.
3) Login Setup to Your MySQL Server:
We all set with our credentials , we are ready to login to the MySQL Server. For that we need to enter into the root of MySQL server. we can enter below command to get into the root.
mysql -u root -p
Once we entered into the root, we will be asked for our own password, which we created in previous steps.
4) Database and Table Creation:
We all set with the MySQL server. To create the database, we can use below command.
Mysql > CREATE DATABASE new_database;
We created our database, now we can get into our database using the following command.
Mysql > use new_database;
Below is the simple structure of table creation.
CREATE TABLE example ( emp_id INT PRIMARY KEY, emp_name VARCHAR(50), emp_email VARCHAR(50) );