{"id":4658,"date":"2021-02-18T12:25:31","date_gmt":"2021-02-18T12:25:31","guid":{"rendered":"https:\/\/linuxways.net\/?p=4658"},"modified":"2021-02-18T13:19:40","modified_gmt":"2021-02-18T13:19:40","slug":"how-to-install-mysql-version-8-on-red-hat-enterprise-linux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-mysql-version-8-on-red-hat-enterprise-linux-8\/","title":{"rendered":"How to Install MySQL Version 8 on Red Hat Enterprise Linux 8"},"content":{"rendered":"<p>MySQL is the most widely used open-source database management system, particularly in the area of application development. This guide describes how to install MySQL version 8 (the latest at the time of writing) via the MySQL yum repository on Red Hat Enterprise Linux (RHEL) 8.<\/p>\n<h2>Prerequisite<\/h2>\n<p>You need to have sudo or root privileges in order to install MySQL on your system.<\/p>\n<h2>Add the MySQL Yum Repository<\/h2>\n<p>First of all, run the command below to download the MySQL Yum repository package for RHEL 8.<\/p>\n<pre>$ <strong>wget https:\/\/dev.mysql.com\/get\/mysql80-community-release-el8-1.noarch.rpm<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"765\" height=\"283\" class=\"wp-image-4659\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-328.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-328.png 765w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-328-300x111.png 300w\" sizes=\"auto, (max-width: 765px) 100vw, 765px\" \/><\/strong><\/p>\n<p>Next, install the downloaded MySQL Yum repository package as follows.<\/p>\n<pre>$ <strong>sudo yum install https:\/\/dev.mysql.com\/get\/mysql80-community-release-el8-1.noarch.rpm<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"261\" class=\"wp-image-4660\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-329.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-329.png 767w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-329-300x102.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/strong><\/p>\n<p>Run the next command to verify that the MySQL Yum repository was successfully added.<\/p>\n<pre>$<strong> yum repolist enabled | grep -i mysql<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"669\" height=\"65\" class=\"wp-image-4661\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-330.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-330.png 669w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-330-300x29.png 300w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/strong><\/p>\n<h2>Install MySQL Version 8<\/h2>\n<p>Once the MySQL Yum repository has been successfully added, you may now install MySQL with the command below.<\/p>\n<pre>$ <strong>sudo yum install mysql-community-server<\/strong><\/pre>\n<p><strong>Note:<\/strong> If you get an error message indicating that a match could not be found for the mysql-community-server, then you may need to first run the next command to disable the MySQL module.<\/p>\n<p>Apparently, this module hides packages provided by MySQL repositories. Once the MySQL module has been successfully disabled, you may run the previous command again to install MySQL.<\/p>\n<pre>$ <strong>sudo yum module disable mysql<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"771\" height=\"319\" class=\"wp-image-4662\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-331.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-331.png 771w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-331-300x124.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-331-768x318.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/strong><\/p>\n<p>After the installation completes successfully, run the command below to verify the version of MySQL.<\/p>\n<pre>$ <strong>mysql --version<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"51\" class=\"wp-image-4663\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-332.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-332.png 579w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-332-300x26.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/strong><\/p>\n<h2>Start the MySQL Server<\/h2>\n<p>Run the following command to start the MySQL server.<\/p>\n<pre>$ <strong>sudo systemctl start mysqld<\/strong><\/pre>\n<p>Next, verify that the MySQL server started successfully with the command below<\/p>\n<pre>$ <strong>sudo systemctl status mysqld<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"751\" height=\"273\" class=\"wp-image-4664\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-333.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-333.png 751w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-333-300x109.png 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/strong><\/p>\n<h2>Secure the MySQL Server<\/h2>\n<p>Run the command below to retrieve the temporary password that was automatically created during installation for the MySQL root user.<\/p>\n<pre>$ <strong>sudo grep 'temporary password' \/var\/log\/mysqld.log<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"775\" height=\"51\" class=\"wp-image-4665\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-334.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-334.png 775w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-334-300x20.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-334-768x51.png 768w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/strong><\/p>\n<p>Next, run the mysql_secure_installation script with the command below.<\/p>\n<pre>$ <strong>sudo mysql_secure_installation<\/strong><\/pre>\n<p>When prompted, enter the temporary password you retrieved in the previous step. You should be prompted to:<\/p>\n<ol>\n<li>Set a new password<\/li>\n<li>Remove anonymous users<\/li>\n<li>Disallow root login remotely<\/li>\n<li>Remove test database<\/li>\n<li>Reload the privilege tables<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"163\" class=\"wp-image-4666\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-335.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-335.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-335-300x67.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<h2>Login to MySQL<\/h2>\n<p>After the mysql_secure_installation script completes, you may now login to MySQL with the command below.<\/p>\n<pre>$ <strong>mysql -u root -p<\/strong><\/pre>\n<p>Once logged in, let us create a sample database.<\/p>\n<pre>mysql&gt; <strong>CREATE DATABASE company;<\/strong><\/pre>\n<pre>mysql&gt; <strong>USE company;<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"646\" height=\"304\" class=\"wp-image-4667\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-336.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-336.png 646w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-336-300x141.png 300w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/strong><\/p>\n<p>Also, let us create a table as well as some records as follows.<\/p>\n<pre>mysql&gt; <strong>CREATE TABLE departments ( dept_name varchar(25), dept_head varchar(25), dept_code char(7), PRIMARY KEY (dept_code) );<\/strong><\/pre>\n<pre>mysql&gt; <strong>INSERT INTO departments VALUES (\u2018Information Technology\u2019, \u2018Olushola Akinye\u2019, \u2018IT\u2019), (\u2018Human Resources\u2019, \u2018Jane Doe\u2019, \u2018HR\u2019), (\u2018Digital Marketing\u2019, \u2018Peter Lagbaja\u2019, \u2018DMKT\u2019);<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"150\" class=\"wp-image-4668\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-337.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-337.png 664w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-337-300x68.png 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/strong><\/p>\n<p>Now, we can display all records in the department&#8217;s table with the following query.<\/p>\n<pre>mysql&gt; <strong>SELECT * FROM departments;<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"566\" height=\"140\" class=\"wp-image-4669\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-338.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-338.png 566w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-338-300x74.png 300w\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" \/><\/strong><\/p>\n<h2>Remove or Uninstall MySQL<\/h2>\n<p>If you would like to remove MySQL at any time, run the following command on the terminal.<\/p>\n<pre>sudo yum remove mysql-community*<\/pre>\n<h2>Conclusion<\/h2>\n<p>If you followed all the steps above, you should now have a fully functioning MySQL server version 8 running on Red Hat Enterprise Linux 8. Feel free to reach out to us if anything is unclear or if you have any comments regarding this article.<\/p>","protected":false},"excerpt":{"rendered":"<p>MySQL is the most widely used open-source database management system, particularly in the area of application development. This guide describes how to install MySQL version 8 (the latest&hellip;<\/p>","protected":false},"author":28,"featured_media":4670,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[27,198],"class_list":["post-4658","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-mysql","tag-red-hat-enterprise-linux-8"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/4658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=4658"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/4658\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/4670"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=4658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=4658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=4658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}