博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
debian安装mysql_如何在Debian 10上安装最新MySQL
阅读量:2506 次
发布时间:2019-05-11

本文共 10757 字,大约阅读时间需要 35 分钟。

debian安装mysql

介绍 (Introduction)

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.

是一个杰出的开源数据库管理系统,用于存储和检索各种流行应用程序的数据。 MySQL是LAMP堆栈中的MLAMP堆栈是一组常用的开源软件,还包括Linux,Apache Web服务器和PHP编程语言。

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.

在Debian 10中,MariaDB(MySQL项目的一个社区分支)被打包为默认MySQL变体。 尽管MariaDB在大多数情况下都能正常运行,但是如果您需要仅在Oracle MySQL中才能找到的功能,则可以从MySQL开发人员维护的存储库中安装和使用软件包。

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.

要安装最新版本MySQL,我们将添加此存储库,安装MySQL软件本身,确保安装的安全性,最后我们将测试MySQL是否正在运行并响应命令。

先决条件 (Prerequisites)

Before starting this tutorial, you will need:

在开始本教程之前,您需要:

  • One Debian 10 server set up by following , including a non-root user with sudo privileges and a firewall.

    通过遵循设置一台Debian 10服务器,包括具有sudo特权的非root用户和防火墙。

第1步-添加MySQL软件存储库 (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.

MySQL开发人员提供了一个.deb软件包,用于配置和安装官方MySQL软件存储库。 设置好存储库后,我们将能够使用Debian的标准apt命令来安装软件。

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

在执行此操作之前,我们需要安装必备的软件包,这是的开源实现。

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

让我们首先更新本地包索引以反映最新的上游更改:

  • sudo apt update

    sudo apt更新

Then, install the gnupg package:

然后,安装gnupg软件包:

  • sudo apt install gnupg

    sudo apt安装gnupg

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

确认安装后,apt将安装gnupg及其依赖项。

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

接下来,我们将使用wget下载MySQL .deb软件包,然后使用dpkg命令进行安装。

Load 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).

在Web浏览器中加载 。 在右下角找到“ 下载”按钮,然后单击进入下一页。 该页面将提示您登录或注册Oracle Web帐户。 我们可以跳过该链接,而是寻找表示“ 不,谢谢”的链接,只需开始下载即可 。 右键单击链接,然后选择“ 复制链接地址” (此选项的措词可能有所不同,具体取决于您的浏览器)。

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:

现在我们将下载文件。 在服务器上,移至您可以写入的目录。 使用wget下载文件,记得将刚复制的地址粘贴到下面突出显示的部分:

  • cd /tmp

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

    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:

现在应该将文件下载到我们的当前目录中。 列出文件以确保:

  • ls

    ls

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 -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.

dpkg用于安装,删除和检查.deb软件包。 -i标志指示我们要从指定的文件安装。

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.

在安装过程中,将为您提供一个配置屏幕,您可以在其中指定所需MySQL版本,并可以选择安装其他MySQL相关工具的存储库。 默认值将添加最新稳定版本MySQL的存储库信息,仅此而已。 这就是我们想要的,因此请使用向下箭头导航至“ Ok菜单选项,然后按ENTER

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

软件包现在将完成添加存储库。 刷新您的apt软件包缓存以使新软件包可用:

  • sudo apt update

    sudo apt更新

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.

既然我们已经添加了MySQL存储库,就可以安装实际MySQL服务器软件了。 如果您需要更新这些存储库的配置,只需运行sudo dpkg-reconfigure mysql-apt-config ,选择新选项,然后执行sudo apt-get update刷新包缓存。

第2步-安装MySQL (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:

添加了存储库并更新了软件包缓存后,我们现在可以使用apt安装最新MySQL服务器软件包:

  • sudo apt install mysql-server

    sudo apt安装mysql服务器

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.

apt将查看所有可用的mysql-server软件包,并确定MySQL提供的软件包是最新和最佳的软件包。 然后它将计算软件包的依赖关系,并要求您批准安装。 键入y然后按ENTER 。 该软件将安装。

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.

在安装的配置阶段,将要求您设置root密码。 选择并确认安全密码以继续。 接下来,将出现提示,要求您选择默认的身份验证插件。 阅读显示内容以了解选择。 如果不确定,请选择“ 使用强密码加密”

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

MySQL应该已经安装并正在运行。 让我们使用systemctl进行systemctl

  • sudo systemctl status mysql

    sudo systemctl状态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/mysqldJul 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.

Active: active (running)行表示MySQL已安装并正在运行。 现在,我们将使安装更加安全。

步骤3 —保护MySQL (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附带了一个命令,我们可以使用该命令在新安装的系统上执行一些与安全性相关的更新。 现在运行它:

  • mysql_secure_installation

    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:

这将要求您提供在安装过程中设置MySQL root密码。 ENTER它,然后按ENTER 。 现在,我们将回答一系列的是或否提示。 让我们来看看它们:

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.

首先,询问我们有关validate password插件的问题 ,该插件可以为您MySQL用户自动执行某些密码强度规则。 启用此功能是您需要根据个人安全需求做出的决定。 键入y ENTER以启用它,或直接按ENTER跳过它。 如果启用,还将提示您从0–2中选择一个级别,以验证密码验证的严格程度。 选择一个数字,然后按ENTER继续。

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.

接下来,将询问您是否要更改root密码。 由于我们是在安装MySQL时才创建密码的,因此可以安全地跳过此步骤。 按ENTER继续而不更新密码。

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.

其余提示可以回答“ 是” 。 系统将询问您有关删除匿名 MySQL用户,不允许远程root登录,删除测试数据库以及重新加载特权表以确保先前的更改正确生效的问题。 这些都是好主意。 ENTER y并为每个ENTER

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.

回答所有提示后,脚本将退出。 现在我们MySQL安装已得到合理保护。 让我们通过运行连接到服务器并返回一些信息的客户端来再次对其进行测试。

步骤4 –测试MySQL (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是MySQL的命令行管理客户端。 我们将使用它来连接到服务器并输出一些版本和状态信息:

  • mysqladmin -u root -p version

    mysqladmin -u root -p版本

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.

-u root部分告诉mysqladmin以MySQL 用户身份登录, -p指示客户端要求输入密码,而version是我们要运行的实际命令。

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

输出将使我们知道正在运行哪个版本MySQL服务器,其正常运行时间以及其他一些状态信息:

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 itsaffiliates. Other names may be trademarks of their respectiveowners.Server version 8.0.17Protocol version 10Connection Localhost via UNIX socketUNIX socket /var/run/mysqld/mysqld.sockUptime: 3 min 9 secThreads: 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.

此输出确认您已成功安装并保护了最新MySQL服务器。

结论 (Conclusion)

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

现在,您已经安装了最新的稳定版本MySQL,该版本应适用于许多流行的应用程序。

翻译自:

debian安装mysql

转载地址:http://zmhgb.baihongyu.com/

你可能感兴趣的文章
Mysql 创建存储过程 更新表
查看>>
Qt Creator键盘快捷键速查
查看>>
Jquery Ajax处理,服务端三种页面aspx,ashx,asmx的比较
查看>>
JVM读书笔记PART3
查看>>
php上传文件如何保证上传文件不被改变或者乱码
查看>>
目录遍历代码
查看>>
iOS MD5加密实现方法
查看>>
页面中调用系统常用的对话框需要用到的classid
查看>>
cygwin下的目录软连接
查看>>
eclipse控制台不显示输出的解决办法
查看>>
Java中的TCP/UDP网络通信编程
查看>>
Trie树
查看>>
Mysql支持的数据类型(总结)
查看>>
对测试转开发的一些想法
查看>>
MVC文件上传08-使用客户端jQuery-File-Upload插件和服务端Backload组件让每个用户有专属文件夹...
查看>>
html模板中调用变量
查看>>
pacs dicom3.0 DCMTK EFilm
查看>>
大气登录页面
查看>>
应用程序缓存的应用(摘抄)
查看>>
洛谷 P2119 魔法阵 题解
查看>>