请在 Ubuntu 18.04 LTS 上安装 MariaDB 10.4

让我们在Ubuntu 18.04 LTS上安装MariaDB 10.4。

MariaDB仓库设置

使用在 MariaDB Package Repository Setup and Usage 中提到的一行命令来设置仓库。

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

如果您希望使用MariaDB Server 10.3,请更改版本号后生成以下文件。

# MariaDB Server
deb http://downloads.mariadb.com/MariaDB/mariadb-10.4/repo/ubuntu bionic main

# MariaDB MaxScale
deb http://downloads.mariadb.com/MaxScale/2.4/ubuntu bionic main

# MariaDB Tools
deb http://downloads.mariadb.com/Tools/ubuntu bionic main

执行约定的 apt-get update / upgrade。

# apt-get -y update 
# apt-get -y upgrade 

安装mariadb-server-10.4。

使用“apt list”命令来查看软件包的名称。

# apt list | grep -i mariadb-server
mariadb-server/unknown 1:10.4.12+maria~bionic all
mariadb-server-10.1/bionic-updates,bionic-security 1:10.1.44-0ubuntu0.18.04.1 amd64
mariadb-server-10.4/unknown 1:10.4.12+maria~bionic amd64
mariadb-server-core-10.1/bionic-updates,bionic-security 1:10.1.44-0ubuntu0.18.04.1 amd64
mariadb-server-core-10.4/unknown 1:10.4.12+maria~bionic amd64

安装 Mariadb 服务器版本 10.4。

# apt install mariadb-server-10.4 -y

使用”dpkg -l”命令来确认已安装的软件包。

# dpkg -l | grep -i mariadb
ii  libdbd-mysql-perl              4.046-1                                     amd64        Perl5 database interface to the MariaDB/MySQL database
ii  libmariadb3:amd64              1:10.4.12+maria~bionic                      amd64        MariaDB database client library
ii  mariadb-client-10.4            1:10.4.12+maria~bionic                      amd64        MariaDB database client binaries
ii  mariadb-client-core-10.4       1:10.4.12+maria~bionic                      amd64        MariaDB database core client binaries
ii  mariadb-common                 1:10.4.12+maria~bionic                      all          MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf)
ii  mariadb-server-10.4            1:10.4.12+maria~bionic                      amd64        MariaDB database server binaries
ii  mariadb-server-core-10.4       1:10.4.12+maria~bionic                      amd64        MariaDB database core server files
ii  mysql-common                   1:10.4.12+maria~bionic                      all          MariaDB database common files (e.g. /etc/mysql/my.cnf)

执行MariaDB监视器

让我们运行mariadb(MariaDB监视器)命令。

# mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 47
Server version: 10.4.12-MariaDB-1:10.4.12+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT CONCAT(user, '@', host, ' => ', JSON_DETAILED(priv)) FROM mysql.global_priv \G
*************************** 1. row ***************************
CONCAT(user, '@', host, ' => ', JSON_DETAILED(priv)): root@localhost => {
    "access": 18446744073709551615,
    "plugin": "mysql_native_password",
    "authentication_string": "invalid",
    "auth_or":
    [

        {
        },

        {
            "plugin": "unix_socket"
        }
    ]
}
*************************** 2. row ***************************
CONCAT(user, '@', host, ' => ', JSON_DETAILED(priv)): mysql@localhost => {
    "access": 18446744073709551615,
    "plugin": "mysql_native_password",
    "authentication_string": "invalid",
    "auth_or":
    [

        {
        },

        {
            "plugin": "unix_socket"
        }
    ]
}

从MariaDB 10.4版本开始,root/mysql用户将启用unix_socket插件。

只需要一个选项,以下是用汉语本地化的改写:
如果按照以下方法创建用户,则可以使用mysql_native_password插件进行用户认证。

MariaDB [(none)]> GRANT ALL ON *.* TO db_user@'localhost' IDENTIFIED BY 'password';
广告
将在 10 秒后关闭
bannerAds