Contents...
MySQL is an open source relational database management system (DBMS) which is much of the time conveyed in a wide grouping of settings. Most every now and again it is conveyed as a feature of the LAMP Stack. The database system is additionally simple to utilize and exceedingly convenient and is, with regards to numerous applications, amazingly productive
In this article I will describe how to install MySQL server on CentOS RHEL and Fedora.
Install and Configure MySQL Yum Repository
First of all you will need to enable MySQL yum repository on your system, typing below command:
On CentOS/RHEL 7 system # rpm -Uvh https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm On CentOS/RHEL 6 system # rpm -Uvh https://repo.mysql.com/mysql57-community-release-el6-11.noarch.rpm On Fedora 26 system # rpm -Uvh https://repo.mysql.com/mysql57-community-release-fc26-10.noarch.rpm On Fedora 25 system # rpm -Uvh https://repo.mysql.com/mysql57-community-release-fc25-10.noarch.rpm On Fedora 24 system # rpm -Uvh https://repo.mysql.com/mysql57-community-release-fc24-10.noarch.rpm
Install MySQL 8.0 Community Server
After adding and enabling yum repository on your system, now install MySQL server:
# yum --enablerepo=mysql80-community install mysql-community-server ## CentOS, RHEL 7 # dnf --enablerepo=mysql80-community install mysql-community-server ## Fedora 26/25/24
Grep MySQL Root Password
After installing MySQL 8.0 you will get a temporary password for MySQL root user. You can find the temporary password in its logs file.
# grep "A temporary password" /var/log/mysqld.log [Note] A temporary password is generated for root@localhost: hosygMikj1+t636
Start MySQL Service
Now start MySQL service typing below command:
# service mysqld start OR # systemctl start mysqld.service
MySQL Post Installation Setup
If you are installing MySQL first time type the below command to secure MySQL server.
# mysql_secure_installation New password: Re-enter new password: The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : No ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done!
Restart MySQL service
After securing MySQL server now restart the MySQL service using below command;
# service mysqld restart OR # systemctl restart mysqld.service
Enable service to start automatically during system reboot:
# chkconfig mysqld on OR # systemctl enable mysqld.service
Connect MySQL Server Using MySQL Client
Now connect MySQL database server using MySQL client:
# mysql -h localhost -u root -p Type your password here..
Run the following command to create new database, create a user and assign privileges to the user on the database.
## CREATE DATABASE mysql> CREATE DATABASE testdb; ## CREATE USER ACCOUNT mysql> CREATE USER 'dbuser'@'%' IDENTIFIED BY 'password'; ## GRANT PERMISSIONS ON DATABASE mysql> GRANT ALL ON testdb.* TO 'dbuser'@'%'; ## RELOAD PRIVILEGES mysql> FLUSH PRIVILEGES;
Congratulation’s!
You have successfully installed MySQL server on your system.
Thanks:)
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Thank you team for the article on mysql installation, Is there a way to change the default installation directory to a new location while trying to install the software. I have created a new mount only for mysql and if I need to have the everything installed and pointed to the new disk while installation what I need to do.? Thank You in advance.