{"id":6679,"date":"2016-06-21T23:12:45","date_gmt":"2016-06-21T15:12:45","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=6679"},"modified":"2023-04-28T09:47:06","modified_gmt":"2023-04-28T09:47:06","slug":"install-mysql-on-centos-7","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/install-mysql-on-centos-7\/","title":{"rendered":"How to Install MySQL on CentOS 7 \/ RHEL 7 \/ Oracle Linux 7 instead of MariaDB"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone wp-image-6687 size-full lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2016\/06\/How-to-Install-MySQL-on-CentOS-7.jpg\" alt=\"how to install mysql\" width=\"1280\" height=\"1046\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2016\/06\/How-to-Install-MySQL-on-CentOS-7.jpg 1280w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2016\/06\/How-to-Install-MySQL-on-CentOS-7-300x245.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2016\/06\/How-to-Install-MySQL-on-CentOS-7-768x628.jpg 768w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2016\/06\/How-to-Install-MySQL-on-CentOS-7-1024x837.jpg 1024w\" data-sizes=\"(max-width: 1280px) 100vw, 1280px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1280px; --smush-placeholder-aspect-ratio: 1280\/1046;\" \/><\/p>\n<p>By default, CentOS 7, RHEL 7, and Oracle Linux 7 come with MariaDB, a drop-in replacement for MySQL. However, in some cases, you might prefer to use the original MySQL instead of MariaDB. In this guide, we will demonstrate how to install MySQL on CentOS 7, RHEL 7, and Oracle Linux 7 instead of MariaDB.<\/p>\n<h2>Step 1: Remove MariaDB if installed<\/h2>\n<p>If MariaDB is installed on your system, you need to remove it first. To uninstall MariaDB and its dependencies, execute the following command:<\/p>\n<pre>\r\nsudo yum remove -y mariadb mariadb-server\r\n<\/pre>\n<h2>Step 2: Add the MySQL Yum repository<\/h2>\n<p>To install MySQL, you need to add the MySQL Yum repository. Download the MySQL Yum repository RPM package using the following command:<\/p>\n<pre>\r\nwget https:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-8.noarch.rpm\r\n<\/pre>\n<p>Install the downloaded MySQL repository RPM package:<\/p>\n<pre>\r\nsudo rpm -Uvh mysql57-community-release-el7-8.noarch.rpm\r\n<\/pre>\n<p>This command adds the MySQL repository to your system.<\/p>\n<h2>Step 3: Install MySQL<\/h2>\n<p>With the MySQL repository added, you can now install MySQL using the following command:<\/p>\n<pre>\r\nsudo yum install -y mysql-community-server\r\n<\/pre>\n<p>This command installs the MySQL server and its dependencies on your system.<\/p>\n<h2>Step 4: Start and enable the MySQL service<\/h2>\n<p>Start the MySQL service:<\/p>\n<pre>\r\nsudo systemctl start mysqld\r\n<\/pre>\n<p>Enable the MySQL service to start automatically on system boot:<\/p>\n<pre>\r\nsudo systemctl enable mysqld\r\n<\/pre>\n<h2>Step 5: Secure the MySQL installation<\/h2>\n<p>Run the MySQL security script to secure your MySQL installation:<\/p>\n<pre>\r\nsudo mysql_secure_installation\r\n<\/pre>\n<p>The script will prompt you to configure several security settings, such as setting a root password, removing anonymous users, disallowing remote root login, and removing the test database.<\/p>\n<pre># sudo mysql_secure_installation\r\n\r\nSecuring the MySQL server deployment.\r\n\r\nEnter password for user root:\r\nThe 'validate_password' plugin is installed on the server.\r\nThe subsequent steps will run with the existing configuration\r\nof the plugin.\r\nUsing existing password for root.\r\n\r\nEstimated strength of the password: 50\r\nChange the password for root ? ((Press y|Y for Yes, any other key for No) : yes\r\n\r\nNew password:\r\n\r\nRe-enter new password:\r\n\r\nEstimated strength of the password: 50\r\nDo you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y\r\nBy default, a MySQL installation has an anonymous user,\r\nallowing anyone to log into MySQL without having to have\r\na user account created for them. This is intended only for\r\ntesting, and to make the installation go a bit smoother.\r\nYou should remove them before moving into a production\r\nenvironment.\r\n\r\nRemove anonymous users? (Press y|Y for Yes, any other key for No) : y\r\nSuccess.\r\n\r\n\r\nNormally, root should only be allowed to connect from\r\n'localhost'. This ensures that someone cannot guess at\r\nthe root password from the network.\r\n\r\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : no\r\n\r\n ... skipping.\r\nBy default, MySQL comes with a database named 'test' that\r\nanyone can access. This is also intended only for testing,\r\nand should be removed before moving into a production\r\nenvironment.\r\n\r\n\r\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : y\r\n - Dropping test database...\r\nSuccess.\r\n\r\n - Removing privileges on test database...\r\nSuccess.\r\n\r\nReloading the privilege tables will ensure that all changes\r\nmade so far will take effect immediately.\r\n\r\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : y\r\nSuccess.\r\n\r\nAll done!\r\n<\/pre>\n<h2>Programs Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">MariaDB<\/span> &#8211; A drop-in replacement for MySQL that is the default database system in CentOS 7, RHEL 7, and Oracle Linux 7.<\/li>\n<li><span class=\"fw-bold\">MySQL<\/span> &#8211; An open-source relational database management system.<\/li>\n<li><span class=\"fw-bold\">yum<\/span> &#8211; The default package manager for CentOS and RHEL, used to install, update, and manage software packages on the system.<\/li>\n<li><span class=\"fw-bold\">systemctl<\/span> &#8211; A utility for controlling the systemd system and service manager, which is used to manage services on CentOS 7, RHEL 7, and Oracle Linux 7.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>You have successfully installed MySQL on CentOS 7, RHEL 7, or Oracle Linux 7 instead of MariaDB. You can now use the MySQL server to manage your databases and applications that depend on MySQL. Remember to keep your MySQL installation up-to-date with security patches and new features by regularly running sudo yum update.<\/p>\n<p>If you have any questions, comments, or suggestions for improvements, please feel free to share your thoughts. Your feedback helps us provide the most accurate and useful information possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, CentOS 7, RHEL 7, and Oracle Linux 7 come with MariaDB, a drop-in replacement for MySQL. However, in some cases, you might prefer to use the original MySQL&#8230;<\/p>\n","protected":false},"author":6,"featured_media":6687,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1008],"tags":[1258,1975,1585],"class_list":["post-6679","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-centos-7","tag-install","tag-mysql"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/6679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=6679"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/6679\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6687"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=6679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=6679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=6679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}