Linux debian install mysql

How To Install the Latest MySQL on Debian 10

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.

In this tutorial, you will install the latest version of MySQL by adding this repository, install the MySQL software itself, secure the install, and test that MySQL is running and responding to commands.

Prerequisites

Before starting this tutorial, you will need one Debian 10 server that has a non-root user with sudo privileges and a firewall configured. You can do this by following our initial server setup guide for Debian 10.

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, you’ll be able to use Debian’s standard apt command to install the software.

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

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, you’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. You can skip that and find 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 you’re going to download the file. On your server, move to a directory you can write to, such as the temporary /tmp directory used in this example:

Читайте также:  Linux colored terminal output

Next, download the file using wget , remembering to paste the address you copied in place of the highlighted portion in the following command:

The file should now be downloaded in your current directory. List the files to confirm:

The output will return a list of various files, including the one you just downloaded, which is highlighted in the following example:

Output
. . . mysql-apt-config_0.8.22-1_all.deb . . .

Now you’re ready for installation. Run the dpkg command which is used to install, remove, and inspect .deb software packages. The -i flag indicates that you’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 will choose for our purposes, 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 you’ve added the MySQL repositories, you’re ready to install the actual MySQL server software. If you ever need to update the configuration of these repositories, 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 your package cache freshly updated, now you can use apt to install the latest MySQL server package:

apt will scan 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. Write 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 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. Check by using systemctl :

Output
● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en Active: active (running) since Thu 2022-02-24 18:59:22 UTC; 23min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 3722 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 4915) Memory: 371.7M CGroup: /system.slice/mysql.service └─3722 /usr/sbin/mysqld Feb 24 18:59:21 sql-debian systemd[1]: Starting MySQL Community Server. Feb 24 18:59:22 sql-debian systemd[1]: Started MySQL Community Server.

The Active: active (running) line means MySQL is installed and running. In the next step, you’ll make the installation a little more secure.

Читайте также:  Arch linux grub install efi

Step 3 — Securing MySQL

MySQL comes with a command to perform a few security-related updates on your new install. You can run it now:

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

First, you’re 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. Write y and press ENTER to enable it, or press 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 press ENTER to continue.

Next you’ll be asked if you want to change the root password. Since you recently created the password when you installed MySQL, you can safely skip this. Press ENTER to continue without updating the password.

The rest of the prompts can be answered yes. You will be asked about removing anonymous MySQL users, disallowing remote root logins, removing the test database, and reloading privilege tables to ensure the previous changes take effect properly. These are all good ideas. Write y and press ENTER for each.

The script will exit after all the prompts are answered. Now your MySQL installation is reasonably secured. Next you’ll 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. You’ll use it to connect to the server and output some version and status information. 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 you want to run:

The output will result in what version of the MySQL server is running, its uptime, and some other status information as in the following:

Output
mysqladmin Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL) Copyright (c) 2000, 2022, 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.28 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 25 min 31 sec Threads: 2 Questions: 20 Slow queries: 0 Opens: 143 Flush tables: 3 Open tables: 62 Queries per second avg: 0.013

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

Читайте также:  Linux iphone file transfer

Conclusion

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

For more information about the basics of MySQL, we encourage you to check out the following tutorials:

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Still looking for an answer?

This textbox defaults to using Markdown to format your answer. You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Setting up mysql-community-server (8.0.18-1debian10) . Failed to preset unit: File mysql.service: Link has been severed /usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory Failed to get unit file state for mysql.service: Link has been severed mysql.service is a disabled or a static unit, not starting it. Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. invoke-rc.d: initscript mysql, action "start" failed. ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-11-18 01:55:38 UTC; 10ms ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 2589 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Process: 2624 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE) Main PID: 2624 (code=exited, status=1/FAILURE) Status: "Data Dictionary upgrade from MySQL 5.7 in progress" Nov 18 01:55:37 debian10 systemd[1]: Starting MySQL Community Server. Nov 18 01:55:38 debian10 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE Nov 18 01:55:38 debian10 systemd[1]: mysql.service: Failed with result 'exit-code'. Nov 18 01:55:38 debian10 systemd[1]: Failed to start MySQL Community Server. dpkg: error processing package mysql-community-server (--configure): installed mysql-community-server package post-installation script subprocess returned error exit status 1 dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-community-server (= 8.0.18-1debian10); however: Package mysql-community-server is not configured yet. dpkg: error processing package mysql-server (--configure): dependency problems - leaving unconfigured Errors were encountered while processing: mysql-community-server mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1) 

Hello, First of all During step 1, I have an infinite loop on asking me: (1) MySQL Server & Cluster (Currently selected: mysql-8.0) (2) mysql-8.0 After escaping this infinite modal window, during step 2 — Installing MySQL, for debian 10 I have: E: Package ‘mysql-server’ has no installation candidate. Do you have any clue?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Источник

Оцените статью
Adblock
detector