{"id":17263,"date":"2024-05-22T14:13:08","date_gmt":"2024-05-22T14:13:08","guid":{"rendered":"https:\/\/hostvento.com\/kb\/web-hosting\/how-to-install-the-latest-mysql-on-ubuntu-18-04\/"},"modified":"2024-06-17T07:51:07","modified_gmt":"2024-06-17T07:51:07","slug":"how-to-install-the-latest-mysql-on-ubuntu-18-04","status":"publish","type":"docs","link":"https:\/\/www.hostvento.com\/kb\/docs\/hosting-faqs\/how-to-install-the-latest-mysql-on-ubuntu-18-04\/","title":{"rendered":"How To Install the Latest MySQL on Ubuntu 18.04?"},"content":{"rendered":"\n<p>MySQL is a well-known open source database management system that stores and retrieves data for a number of well-known applications. In the context of the LAMP stack, which is a widely used collection of open source software that also includes PHP, Linux, and the Apache web server, M stands for MySQL.<\/p>\n\n\n\n<p>It is frequently necessary to install a more recent version of MySQL than what your Linux distribution offers in order to use the recently announced features. The MySQL developers have the convenience of maintaining their own software repository, which we may utilize to effortlessly install and maintain the most recent version.<\/p>\n\n\n\n<p>For installing the latest version of MySQL, we will add this repository, install the MySQL software itself, secure the install, and lastly test that MySQL is running and is responsive to commands.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p>Prior to starting this tutorial, you will need:<br>\u2022 An Ubuntu 18.04 server with a non-root and sudo-enabled user.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1 \u2014 Adding the MySQL Software Repository<\/h3>\n\n\n\n<p>You get a .deb package offered by the MySQL developers that manages the configuration and installation of the official MySQL software repositories. After setting up the repositories, user can use Ubuntu\u2019s standard apt command for software installation. Then download this .deb file with curl and then install it with the dpkg command.<\/p>\n\n\n\n<p>Now, load the MySQL download page in your web browser. The Download button is in the lower-right corner, click via to the next page. You will be prompted for log in or sign up for an Oracle account. Skip this and find the link that says No thanks, just start my download. Now, right-click the link and select Copy Link Address (this option may be different, based on your browser).<\/p>\n\n\n\n<p>Now, you will be downloading the file. Move to a directory that you can write to on your server with the below command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd \/tmp<\/pre>\n\n\n\n<p>Use&nbsp;<em>curl<\/em>&nbsp;to download the file and paste the address you just copied in place of the highlighted portion below:<\/p>\n\n\n\n<p>$&nbsp;curl -0L&nbsp;&nbsp;https:\/\/dev.mysql.com\/get\/mysql-apt-config_0.8.10-1_all.deb<\/p>\n\n\n\n<p>It is important to pass two command line flags to&nbsp;<em>curl<\/em>.&nbsp;<em>-0<\/em>&nbsp;asks&nbsp;<em>curl<\/em>&nbsp;to output to a file rather than the standard output.<\/p>\n\n\n\n<p>The&nbsp;<em>L<\/em>&nbsp;flag helps&nbsp;<em>curl<\/em>&nbsp;follow HTTP redirects, which is essential in this case as the address you copied actually redirects you to another location prior to the file downloads.<\/p>\n\n\n\n<p>With this, the file should be downloaded in your current directory. For ensuring, list the files:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ 1s<\/pre>\n\n\n\n<p>You will see the filename listed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Output\nmysql-apt-config_0.8.10-1_all.deb\n. . .<\/pre>\n\n\n\n<p>Now you ready to install:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo dpkg -i mysql-apt-config*<\/pre>\n\n\n\n<p>With&nbsp;<em>dpkg<\/em>&nbsp;you can install, remove, and inspect&nbsp;<em>.deb<\/em>&nbsp;software packages. The&nbsp;<em>-i<\/em>&nbsp;flag signifies that you would install from the specified file.<\/p>\n\n\n\n<p>While the installation continues, you will get a configuration screen displayed where you need to enter the version of MySQL of your choice in addition to an option for installing repositories for other MySQL-related tools. The repository information for the latest stable version of MySQL will be added by the defaults. This is what is expected so, use the down arrow to navigate to the&nbsp;<em>OK<\/em>&nbsp;menu option and hit&nbsp;<em>ENTER<\/em>.<\/p>\n\n\n\n<p>Now, the package will finish adding the repository. To make the new software packages available, refresh your apt package cache:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt update<\/pre>\n\n\n\n<p>Also, it is important to clean up and delete the file that you downloaded:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ rm mysql-apt-config*<\/pre>\n\n\n\n<p>Now, you have added the MySQL repositories and so, you are ready to install the actual MySQL server software. In case, you need to update the configuration of these repositories, simply run&nbsp;<em>sudo dpkg-reconfigure mysql-apt-config<\/em>, select new options, and then sudo apt update to refresh your package cache.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2 \u2014 Installing MySQL<\/h3>\n\n\n\n<p>After adding the repository and with your package cache freshly updated, you can now use apt to install the latest MySQL server package:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt install mysql-server<\/pre>\n\n\n\n<p>All available&nbsp;<em>mysql-server<\/em>&nbsp;packages will be looked at by&nbsp;<em>apt<\/em>&nbsp;and verified that the MySQL provided package is the newest and best candidate. After that the package dependencies will be calculated and you will be asked to approve the installation. Type&nbsp;<em>y<\/em>&nbsp;then press&nbsp;<em>ENTER<\/em>. The software will get installed.<\/p>\n\n\n\n<p>Then you will need to set a root password during the configuration phase of the installation. Make sure you select a secure password. After entering it twice, hit&nbsp;<em>ENTER<\/em>. You will be asked to configure an authentication plugin. The&nbsp;<strong>Use Strong Password Encryption<\/strong>&nbsp;is recommended to be default, so hit&nbsp;<em>ENTER<\/em>&nbsp;to select it. Now the installation process will continue until it gets completed.<\/p>\n\n\n\n<p>You will see MySQL is installed and running. To check it use&nbsp;<em>systemctl<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ systemctl status mysql<\/pre>\n\n\n\n<p>The&nbsp;<em>Active: active (running)<\/em>&nbsp;line indicates MySQL is installed and running. Now you will need to make the installation a little more secure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3 \u2014 Securing MySQL<\/h3>\n\n\n\n<p>A command is included in MySQL that you can use for performing a few security related updates on your new install.<\/p>\n\n\n\n<p>Run it now with the below command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ mysql_secure_installation<\/pre>\n\n\n\n<p>Now you will be asked for the MySQL&nbsp;<strong>root<\/strong>&nbsp;password that you set while the installation. Type it and press ENTER. Now you will need to answer a series of yes or no prompts. Go through them:<\/p>\n\n\n\n<p>First, you will be asked about the&nbsp;<strong>validate password plugin<\/strong>, a plugin that can automatically implement certain password strength rules for your MySQL users. When you enable this, it is a decision you\u2019ll need to make depending on your individual security needs. To enable it, type&nbsp;<em>y<\/em>&nbsp;and&nbsp;<em>ENTER<\/em>&nbsp;or simply hit&nbsp;<em>ENTER<\/em>&nbsp;to skip it. If you enable it, you will also be asked to select a level from 0\u20132 for the amount of strictness of the password validation. Select a number and press&nbsp;<em>ENTER<\/em>&nbsp;to continue.<\/p>\n\n\n\n<p>Next you\u2019ll be asked for changing the root password, if required. Since you have just created the password while installing the MySQL, you can skip this. Press&nbsp;<em>ENTER<\/em>&nbsp;to continue without changing the password.<\/p>\n\n\n\n<p>Answer<strong>&nbsp;\u2018yes\u2019<\/strong>&nbsp;to the rest of the prompts. Now, you will be prompted for removing the&nbsp;<strong>anonymous<\/strong>&nbsp;MySQL user, removing the&nbsp;<strong>test<\/strong>&nbsp;database, disallowing remote&nbsp;<strong>root<\/strong>&nbsp;login, and reloading privilege tables to make sure that the previous changes take effect. All these are a good idea. Type&nbsp;<em>y<\/em>&nbsp;and press&nbsp;<em>ENTER<\/em>&nbsp;for each.<\/p>\n\n\n\n<p>After all the prompts are answered, the script will exit. Your MySQL installation is reasonably secured now. It is important to test it again by running a client that connects to the server and returns some information.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4 \u2013 Testing MySQL<\/h3>\n\n\n\n<p>A command line administrative client for MySQL is termed as&nbsp;<em>mysqladmin<\/em>. You can use it to connect to the server and output some version and status information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ mysqladmin -u root -p version<\/pre>\n\n\n\n<p>The&nbsp;<em>-u root<\/em>&nbsp;portion indicates&nbsp;<em>mysqladmin<\/em>&nbsp;to log in as the MySQL root user,&nbsp;<em>-p<\/em>&nbsp;indicates the client to prompt for a password, and&nbsp;<em>version<\/em>&nbsp;is the actual command you want to run.<\/p>\n\n\n\n<p>With the output you will know the version of the MySQL server, its uptime, and some other status information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Output\nmysqladmin Ver 8.0.11 for Linux on x86_64 (MySQL Community Server - GPL)\nCopyright (c) 2000, 2018, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nServer version 8.0.11\nProtocol version 10\nConnection Localhost via UNIX socket\nUNIX socket \/var\/run\/mysqld\/mysqld.sock\nUptime: 2 min 21 sec\n\nThreads: 2 Questions: 10 Slow queries: 0 Opens: 136 Flush tables: 2 Open tables: 112 Queries per second avg: 0.070\nIf you get the similar output, it means you have successfully installed the latest MySQL server and secured it.<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>You have successfully finished installing the most recent version of MySQL, which should function for a number of applications. You can go on to other configuration chores if you have more complicated requirements:<\/p>\n\n\n\n<p>A well-liked web-based option for managing your MySQL server using a graphical interface is phpMyAdmin.<\/p>\n\n\n\n<p>As of right now, your database can only interact with programs that are hosted on the same server. For performance and storage reasons, you will typically need separate database and application servers.<\/p>\n\n\n\n<p>The next typical setup involves altering the directory where MySQL keeps its records. This is something that only you will need to perform if you want your data to be stored on a different storage device than the default directory.<\/p>\n\n\n\n<p><a href=\"https:\/\/hostvento.com\/kb\/web-hosting\/learn-to-enable-litespeed-cache-for-wordpress\/\" target=\"_blank\" rel=\"noopener\"><strong>Learn to enable LiteSpeed Cache for WordPress<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL is a well-known open source database management system that stores and retrieves data for a number of well-known applications. In the context of the LAMP stack, which is a widely used collection of open source software that also includes PHP, Linux, and the Apache web server, M stands for MySQL. It is frequently necessary [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":23377,"menu_order":665,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-17263","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/17263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/comments?post=17263"}],"version-history":[{"count":2,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/17263\/revisions"}],"predecessor-version":[{"id":20481,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/17263\/revisions\/20481"}],"up":[{"embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/docs\/23377"}],"wp:attachment":[{"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/media?parent=17263"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hostvento.com\/kb\/wp-json\/wp\/v2\/doc_tag?post=17263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}