如何在Ubuntu,Debian和Mint Kali上安装MySQL?

MySQL is a free and opensource database server which is very popular in the opensource community. MySQL is used by a lot of applications and companies like Facebook, Google, etc. In this tutorial, we will learn how to install MySQL into deb or apt-based distributions like Ubuntu, Debian, Mint, and Kali. This guide can be used for other deb or apt based distributions too.

MySQL是一个免费的开源数据库服务器,在开源社区中非常流行。 许多应用程序和公司(例如Facebook,Google等)都使用MySQL。在本教程中,我们将学习如何将MySQL安装到基于Deb或apt的发行版中,如Ubuntu,Debian,Mint和Kali。 本指南也可用于其他基于debapt的发行版。

更新存储库信息 (Update Repository Information)

It is not a requirement but a best practice to update repository information which will provide us the newest information about MySQL.

这不是必需的,而是更新存储库信息的最佳实践,它将为我们提供有关MySQL的最新信息。

$ sudo apt update
Update Repository Information
Update Repository Information
更新存储库信息

从Apt存储库安装MySQL Server(Install MySQL Server From Apt Repository)

MySQL Server application is named as mysql-server as package name. We can use apt or apt-get in order to install mysql-server package like below. We can also use -y option in order to automatically accept conformation.

MySQL Server应用程序名为mysql-server作为程序包名称。 我们可以使用aptapt-get来安装mysql-server软件包,如下所示。 我们也可以使用-y选项来自动接受构象。

$ sudo apt install mysql-server
Install MySQL Server From Apt Repository
Install MySQL Server From Apt Repository
从Apt存储库安装MySQL Server

下载MySQL服务器二进制文件 (Download MySQL Server Binary)

Another way to install MySQL is from a binary installation file. We can download MySQL binary from official download site mysql.com. But keep in mind that different versions of MySQL Server are provided with different licenses and costs. We will use community version for Ubuntu which can be listed from the following link.

另一种安装MySQL的方法是从二进制安装文件。 我们可以从官方下载站点mysql.com下载MySQL二进制文件。 但是请记住,不同版本MySQL Server具有不同的许可证和成本。 我们将使用Ubuntu的社区版本,可以从以下链接中列出。

https://dev.mysql.com/downloads/mysql/

https://dev.mysql.com/downloads/mysql/

and we will download the deb package with wget.

我们将使用wget下载deb软件包。

$ wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-server_8.0.11-1ubuntu18.04_amd64.deb-bundle.tar
Download MySQL Server Binary
Download MySQL Server Binary
下载MySQL服务器二进制文件

安装MySQL Binary Deb软件包(Install MySQL Binary Deb Package)

After the download is completed we will first extract the tar archive like below.

下载完成后,我们将首先提取tar存档,如下所示。

$ tar xvf mysql-server_8.0.11-1ubuntu18.04_amd64.deb-bundle.tar
Install MySQL Binary Deb Package
Install MySQL Binary Deb Package
安装MySQL Binary Deb软件包

and we will install the mysql-community-server_8.0.11-1ubuntu18.04_amd64.deb  package with dpkg like below.

然后我们将使用dpkg安装mysql-community-server_8.0.11-1ubuntu18.04_amd64.deb软件包,如下所示。

$ sudo dpkg -i mysql-community-server_8.0.11-1ubuntu18.04_amd64.deb

安全MySQL服务器安装 (Secure MySQL Server Installation)

Security is an important part of today’s IT systems. We can make MySQL more secure by using mysql_secure_installation  hardening script. This will run some commands which will change MySQL configuration and harden it. This script will start by asking root password and then ask some questions about security.

安全性是当今IT系统的重要组成部分。 我们可以使用mysql_secure_installation强化脚本来使MySQL更安全。 这将运行一些命令,这些命令将更改MySQL配置并对其进行强化。 该脚本将首先询问root密码,然后询问有关安全性的一些问题。

$ sudo mysql_secure_installation
Secure MySQL Installation
Secure MySQL Installation
安全MySQL安装

显示MySQL服务或守护程序状态(Show MySQL Service or Daemon Status)

After the installation is completed and secured we can list the status of the MySQL server. We will use systemctl command with status option to list whether the MySQL daemon is working or not.

在完成安装并确保其安全之后,我们可以列出MySQL服务器的状态。 我们将使用带有status选项的systemctl命令来列出MySQL守护程序是否正在运行。

$ systemctl status mysql
Show MySQL Service or Daemon Status
Show MySQL Service or Daemon Status
显示MySQL服务或守护程序状态

As we can see the daemon is running properly.

如我们所见,守护程序运行正常。

LEARN MORE  How To List MySQL/MariaDB Databases
了解更多如何列出MySQL / MariaDB数据库

启动MySQL服务/守护程序/服务器(Start MySQL Service/Daemon/Server)

If the MySQL service is not started or stopped with a reason we can start MySQL service with start option like below.

如果由于某种原因未启动或停止MySQL服务,我们可以使用如下所示的start选项来启动MySQL服务。

$ systemctl start mysql

停止MySQL服务/守护程序/服务器 (Stop MySQL Service/Daemon/Server)

If we need to stop the MySQL daemon we can use stop option. This can be useful to apply a new configuration by stopping and starting the service.

如果我们需要停止MySQL守护程序,则可以使用stop选项。 这对于通过停止和启动服务来应用新配置很有用。

$ systemctl stop mysql

通过登录测试MySQL服务器 (Test MySQL Server By Logging In)

We can test the MySQL server by connecting to the service console with mysql command. We also need to provide the username and the password like below.

我们可以通过使用mysql命令连接到服务控制台来测试MySQL服务器。 我们还需要提供用户名和密码,如下所示。

$ mysql -u root -p
Test MySQL Server
Test MySQL Server
测试MySQL服务器

翻译自: https://www.poftut.com/how-to-install-mysql-on-ubuntu-debian-mint-kali/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值