One place for hosting & domains

      Latest

      How To Install the Latest MySQL on Ubuntu 20.04


      Introduction

      MySQL is a prominent open-source relational database management system (RDBMS) used to create, store and retrieve data for a wide variety of popular applications. MySQL is the M in the LAMP stack, a commonly used set of open-source software that also includes Linux, the Apache web server, and the PHP programming language.

      When MySQL releases new features, you may need to install a more up-to-date version than what your Linux distributor provides. For this reason, MySQL developers share their own software repository to install the latest version.

      In this tutorial, you will install the latest version of MySQL. Before doing so, you will need to add the MySQL software repository. Then, you will install the MySQL software itself, secure the install, and verify that MySQL is running and responding to commands.

      Prerequisites

      Before starting this tutorial, you will need:

      Step 1 — Adding the MySQL Software Repository

      The MySQL developers provide a .deb package that configures and installs the official MySQL software repositories. Once the repositories are set up, you will run Ubuntu’s standard apt command to install the software. To do this, you will download the .deb file with curl and then install it with the dpkg command.

      First, load the MySQL download page in your web browser. Find the Download button in the right corner and press it to get to the next page. This page will prompt you to log in or sign up for an Oracle web account. Ignore this and locate the link that says No thanks, just start my download. Right-click the link and select Copy Link Address (this option may be worded differently, depending on your browser).

      Next, you will download the file. On your server, move to a directory you can write to:

      Download the file using curl and replace the highlighted URL with the address you copied from the MySQL Download page:

      • curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.18-1_all.deb

      This command uses two flags with curl. -O instructs curl to output to a file instead of standard output. The L flag makes curl follow HTTP redirects, because the address you copied actually redirects to another location before the file downloads.

      The file is now downloaded in your current directory. List the files to make sure:

      You will see the filename listed:

      Output

      mysql-apt-config_0.8.18-1_all.deb . . .

      Now you can use dpkg to begin the install:

      • sudo dpkg -i mysql-apt-config*

      dpkg is used to install, remove, and inspect .deb software packages. The -i flag requests to install from the specified file.

      During installation, you’ll be prompted with a configuration screen where you can choose which version of MySQL you prefer, and an option to install repositories for other MySQL-related tools.

      Alt text for screen readers

      Since you only want to install the latest version of MySQL, you can choose Ok from the menu options and press ENTER. The repository information you need is already included with the defaults.

      The package will finish adding the repository. Then you can refresh your apt package cache to make the new software packages available:

      Tidy everything up by deleting the file download with the rm command:

      Now that the MySQL repositories are added, you’re ready to install the actual MySQL server software. You can update the configuration of these repositories in the future by running sudo dpkg-reconfigure mysql-apt-config, selecting new options, and then sudo apt update to refresh your package cache.

      Step 2 — Installing MySQL

      With your new repository added and package cache freshly updated, you will use apt to install the latest MySQL server package:

      • sudo apt install mysql-server

      apt identifies all available mysql-server packages and confirms that the MySQL package is the newest version. Then, it will calculate package dependencies and prompt you to approve the installation. Type y then ENTER to proceed with the installation.

      You will be asked to create a root password during the configuration phase of the installation. Be sure to choose a secure password. After you enter the password twice and hit ENTER, you will be asked to configure an authentication plugin. The default of Use Strong Password Encryption is recommended, so press ENTER to choose it. The installation process will continue until finished.

      MySQL is now installed and running. You can check with systemctl:

      Output

      ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: > Active: active (running) since Thu 2021-08-05 22:11:42 UTC; 1min 23s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 5268 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (cod> Main PID: 5322 (mysqld) Status: "Server is operational" Tasks: 37 (limit: 9513) Memory: 353.3M CGroup: /system.slice/mysql.service └─5322 /usr/sbin/mysqld

      MySQL is installed and running if you see Active: active (running). Next, you will secure your installation.

      Step 3 — Securing MySQL

      MySQL comes with a command we can use to perform a few security-related updates on our new install. Run the following command:

      • mysql_secure_installation

      This command will bring up the configuration screen from earlier and ask for the MySQL root password credentials you created upon installation. Type it in and press ENTER. Then, you will answer a series of yes or no prompts. This is what they’ll ask:

      • First, you will be asked whether you want to enable the validate password plugin, a plugin that can automatically enforce certain password strength rules for your MySQL users. Enabling this is a decision you’ll need to make based on your individual security needs. Type y and ENTER to enable it, or press ENTER to skip it. If enabled, you will also be prompted to choose a level from 0–2 on how strict the password validation will be. Choose a number and hit ENTER to continue.

      • Second, you’ll be asked if you want to change the root password. Since you created the password during installation, you can safely skip this. Hit ENTER to continue without updating the password.

      • Lastly, the other prompts can be answered yes. You will be asked about removing the anonymous MySQL user, disallowing remote root login, removing the test database, and reloading privilege tables to ensure the previous changes take effect properly. Type y and hit ENTER for each.

      The configuration screen will disappear after all the prompts are answered. This indicates your MySQL installation is reasonably secured. You can confirm by running a client that connects to the server and returns some information.

      Step 4 – Testing MySQL

      mysqladmin is a command line administrative client for MySQL. You will use it connect to the server and output some version and status information:

      • mysqladmin -u root -p version

      The -u root portion of this command tells mysqladmin to log in as the MySQL root user, -p instructs the client to ask for a password, and version is the actual command we want to run.

      The output will let us know what version of the MySQL server is running, its uptime, and some other status information:

      Output

      mysqladmin Ver 8.0.26 for Linux on x86_64 (MySQL Community Server - GPL) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 8.0.26 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 31 min 1 sec Threads: 2 Questions: 12 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 49 Queries per second avg: 0.006

      This output indicates that you’ve successfully installed and secured the latest MySQL server.

      Conclusion

      You’ve now completed a basic install of the latest version of MySQL, which will work for many popular applications. If you have more advanced needs you can apply some other configuration tasks:



      Source link

      How To Install the Latest MySQL on Debian 10


      Introduction

      MySQL is a prominent open source database management system used to store and retrieve data for a wide variety of popular applications. MySQL is the M in the LAMP stack, a commonly used set of open source software that also includes Linux, the Apache web server, and the PHP programming language.

      In Debian 10, MariaDB, a community fork of the MySQL project, is packaged as the default MySQL variant. While MariaDB works well in most cases, if you need features found only in Oracle’s MySQL, you can install and use packages from a repository maintained by the MySQL developers.

      To install the latest version of MySQL, we’ll add this repository, install the MySQL software itself, secure the install, and finally we’ll test that MySQL is running and responding to commands.

      Prerequisites

      Before starting this tutorial, you will need:

      Step 1 — Adding the MySQL Software Repository

      The MySQL developers provide a .deb package that handles configuring and installing the official MySQL software repositories. Once the repositories are set up, we’ll be able to use Debian’s standard apt command to install the software.

      Before we do this, we need to install the prerequisite GnuPG package, an open-source implementation of the OpenPGP standard.

      Let’s begin by updating the local package index to reflect the latest upstream changes:

      Then, install the gnupg package:

      After confirming the installation, apt will install gnupg and its dependencies.

      Next, we’ll download the MySQL .deb package with wget and then install it using the dpkg command.

      Load the MySQL download page in your web browser. Find the Download button in the lower-right corner and click through to the next page. This page will prompt you to log in or sign up for an Oracle web account. We can skip that and instead look for the link that says No thanks, just start my download. Right-click the link and select Copy Link Address (this option may be worded differently, depending on your browser).

      Now we're going to download the file. On your server, move to a directory you can write to. Download the file using wget, remembering to paste the address you just copied in place of the highlighted portion below:

      • cd /tmp
      • wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb

      The file should now be downloaded in our current directory. List the files to make sure:

      You should see the filename listed:

      Output

      mysql-apt-config_0.8.13-1_all.deb . . .

      Now we're ready to install:

      • sudo dpkg -i mysql-apt-config*

      dpkg is used to install, remove, and inspect .deb software packages. The -i flag indicates that we'd like to install from the specified file.

      During the installation, you'll be presented with a configuration screen where you can specify which version of MySQL you'd prefer, along with an option to install repositories for other MySQL-related tools. The defaults will add the repository information for the latest stable version of MySQL and nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.

      The package will now finish adding the repository. Refresh your apt package cache to make the new software packages available:

      Now that we've added the MySQL repositories, we're ready to install the actual MySQL server software. If you ever need to update the configuration of these repositories, just run sudo dpkg-reconfigure mysql-apt-config, select new options, and then sudo apt-get update to refresh your package cache.

      Step 2 — Installing MySQL

      Having added the repository and with our package cache freshly updated, we can now use apt to install the latest MySQL server package:

      • sudo apt install mysql-server

      apt will look at all available mysql-server packages and determine that the MySQL provided package is the newest and best candidate. It will then calculate package dependencies and ask you to approve the installation. Type y then ENTER. The software will install.

      You will be asked to set a root password during the configuration phase of the installation. Choose and confirm a secure password to continue. Next, a prompt will appear asking for you to select a default authentication plugin. Read the display to understand the choices. If you are not sure, choosing Use Strong Password Encryption is safer.

      MySQL should be installed and running now. Let's check using systemctl:

      • sudo systemctl status mysql
      ● mysql.service - MySQL Community Server
         Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
         Active: active (running) since Thu 2019-07-25 17:20:12 UTC; 3s ago
           Docs: man:mysqld(8)
                 http://dev.mysql.com/doc/refman/en/using-systemd.html
        Process: 2673 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
       Main PID: 2709 (mysqld)
         Status: "Server is operational"
          Tasks: 39 (limit: 4915)
         Memory: 378.4M
         CGroup: /system.slice/mysql.service
                 └─2709 /usr/sbin/mysqld
      
      Jul 25 17:20:10 sammy systemd[1]: Starting MySQL Community Server...
      Jul 25 17:20:12 sammy systemd[1]: Started MySQL Community Server.
      

      The Active: active (running) line means MySQL is installed and running. Now we'll make the installation a little more secure.

      Step 3 — Securing MySQL

      MySQL comes with a command we can use to perform a few security-related updates on our new install. Let's run it now:

      • mysql_secure_installation

      This will ask you for the MySQL root password that you set during installation. Type it in and press ENTER. Now we'll answer a series of yes or no prompts. Let's go through them:

      First, we are asked about the validate password plugin, a plugin that can automatically enforce certain password strength rules for your MySQL users. Enabling this is a decision you'll need to make based on your individual security needs. Type y and ENTER to enable it, or just hit ENTER to skip it. If enabled, you will also be prompted to choose a level from 0–2 for how strict the password validation will be. Choose a number and hit ENTER to continue.

      Next you'll be asked if you want to change the root password. Since we just created the password when we installed MySQL, we can safely skip this. Hit ENTER to continue without updating the password.

      The rest of the prompts can be answered yes. You will be asked about removing the anonymous MySQL user, disallowing remote root login, removing the test database, and reloading privilege tables to ensure the previous changes take effect properly. These are all a good idea. Type y and hit ENTER for each.

      The script will exit after all the prompts are answered. Now our MySQL installation is reasonably secured. Let's test it again by running a client that connects to the server and returns some information.

      Step 4 – Testing MySQL

      mysqladmin is a command line administrative client for MySQL. We'll use it to connect to the server and output some version and status information:

      • mysqladmin -u root -p version

      The -u root portion tells mysqladmin to log in as the MySQL root user, -p instructs the client to ask for a password, and version is the actual command we want to run.

      The output will let us know what version of the MySQL server is running, its uptime, and some other status information:

      Output

      mysqladmin Ver 8.0.17 for Linux on x86_64 (MySQL Community Server - GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 8.0.17 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 3 min 9 sec Threads: 2 Questions: 10 Slow queries: 0 Opens: 128 Flush tables: 3 Open tables: 48 Queries per second avg: 0.052

      This output confirms that you've successfully installed and secured the latest MySQL server.

      Conclusion

      You've now installed the latest stable version of MySQL, which should work for many popular applications.



      Source link

      How To Install the Latest MySQL on Debian 9


      Introduction

      MySQL is a prominent open source database management system used to store and retrieve data for a wide variety of popular applications. MySQL is the M in the LAMP stack, a commonly used set of open source software that also includes Linux, the Apache web server, and the PHP programming language.

      In Debian 9, MariaDB, a community fork of the MySQL project, is packaged as the default MySQL variant. While, MariaDB works well in most cases, if you need features found only in Oracle’s MySQL, you can install and use packages from a repository maintained by the MySQL developers.

      To install the latest version of MySQL, we’ll add this repository, install the MySQL software itself, secure the install, and finally we’ll test that MySQL is running and responding to commands.

      Prerequisites

      Before starting this tutorial, you will need:

      Step 1 — Adding the MySQL Software Repository

      The MySQL developers provide a .deb package that handles configuring and installing the official MySQL software repositories. Once the repositories are set up, we’ll be able to use Ubuntu’s standard apt command to install the software. We’ll download this .deb file with wget and then install it with the dpkg command.

      First, load the MySQL download page in your web browser. Find the Download button in the lower-right corner and click through to the next page. This page will prompt you to log in or sign up for an Oracle web account. We can skip that and instead look for the link that says No thanks, just start my download. Right-click the link and select Copy Link Address (this option may be worded differently, depending on your browser).

      Now we’re going to download the file. On your server, move to a directory you can write to. Download the file using wget, remembering to paste the address you just copied in place of the highlighted portion below:

      • cd /tmp
      • wget https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb

      The file should now be downloaded in our current directory. List the files to make sure:

      You should see the filename listed:

      Output

      mysql-apt-config_0.8.10-1_all.deb . . .

      Now we're ready to install:

      • sudo dpkg -i mysql-apt-config*

      dpkg is used to install, remove, and inspect .deb software packages. The -i flag indicates that we'd like to install from the specified file.

      During the installation, you'll be presented with a configuration screen where you can specify which version of MySQL you'd prefer, along with an option to install repositories for other MySQL-related tools. The defaults will add the repository information for the latest stable version of MySQL and nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.

      The package will now finish adding the repository. Refresh your apt package cache to make the new software packages available:

      Now that we've added the MySQL repositories, we're ready to install the actual MySQL server software. If you ever need to update the configuration of these repositories, just run sudo dpkg-reconfigure mysql-apt-config, select new options, and then sudo apt-get update to refresh your package cache.

      Step 2 — Installing MySQL

      Having added the repository and with our package cache freshly updated, we can now use apt to install the latest MySQL server package:

      • sudo apt install mysql-server

      apt will look at all available mysql-server packages and determine that the MySQL provided package is the newest and best candidate. It will then calculate package dependencies and ask you to approve the installation. Type y then ENTER. The software will install.

      You will be asked to set a root password during the configuration phase of the installation. Choose and confirm a secure password to continue. Next, a prompt will appear asking for you to select a default authentication plugin. Read the display to understand the choices. If you are not sure, choosing Use Strong Password Encryption is safer.

      MySQL should be installed and running now. Let's check using systemctl:

      • sudo systemctl status mysql

      Output

      ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2018-09-05 15:58:21 UTC; 30s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 12805 (mysqld) Status: "SERVER_OPERATING" CGroup: /system.slice/mysql.service └─12805 /usr/sbin/mysqld Sep 05 15:58:15 mysql1 systemd[1]: Starting MySQL Community Server... Sep 05 15:58:21 mysql1 systemd[1]: Started MySQL Community Server.

      The Active: active (running) line means MySQL is installed and running. Now we'll make the installation a little more secure.

      Step 3 — Securing MySQL

      MySQL comes with a command we can use to perform a few security-related updates on our new install. Let's run it now:

      • mysql_secure_installation

      This will ask you for the MySQL root password that you set during installation. Type it in and press ENTER. Now we'll answer a series of yes or no prompts. Let's go through them:

      First, we are asked about the validate password plugin, a plugin that can automatically enforce certain password strength rules for your MySQL users. Enabling this is a decision you'll need to make based on your individual security needs. Type y and ENTER to enable it, or just hit ENTER to skip it. If enabled, you will also be prompted to choose a level from 0–2 for how strict the password validation will be. Choose a number and hit ENTER to continue.

      Next you'll be asked if you want to change the root password. Since we just created the password when we installed MySQL, we can safely skip this. Hit ENTER to continue without updating the password.

      The rest of the prompts can be answered yes. You will be asked about removing the anonymous MySQL user, disallowing remote root login, removing the test database, and reloading privilege tables to ensure the previous changes take effect properly. These are all a good idea. Type y and hit ENTER for each.

      The script will exit after all the prompts are answered. Now our MySQL installation is reasonably secured. Let's test it again by running a client that connects to the server and returns some information.

      Step 4 – Testing MySQL

      mysqladmin is a command line administrative client for MySQL. We'll use it to connect to the server and output some version and status information:

      • mysqladmin -u root -p version

      The -u root portion tells mysqladmin to log in as the MySQL root user, -p instructs the client to ask for a password, and version is the actual command we want to run.

      The output will let us know what version of the MySQL server is running, its uptime, and some other status information:

      Output

      mysqladmin Ver 8.0.12 for Linux on x86_64 (MySQL Community Server - GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 8.0.12 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 6 min 42 sec Threads: 2 Questions: 12 Slow queries: 0 Opens: 123 Flush tables: 2 Open tables: 99 Queries per second avg: 0.029

      If you received similar output, congrats! You've successfully installed the latest MySQL server and secured it.

      Conclusion

      You've now completed a basic install of the latest version of MySQL, which should work for many popular applications.



      Source link