欢迎投稿

今日深度:

CentOS8 安装 MariaDB数据库,依赖关系解决。软件包

CentOS8 安装 MariaDB数据库,依赖关系解决。软件包


创建MariaDB.repo文件

[root@nextcloud etc]# cd yum.repos.d/
[root@nextcloud yum.repos.d]# ls
CentOS-Base.repo                     CentOS-Linux-PowerTools.repo
CentOS-Linux-AppStream.repo          CentOS-Linux-Sources.repo
CentOS-Linux-BaseOS.repo             epel-modular.repo
CentOS-Linux-ContinuousRelease.repo  epel.repo
CentOS-Linux-Debuginfo.repo          epel-testing-modular.repo
CentOS-Linux-Devel.repo              epel-testing.repo
CentOS-Linux-Extras.repo             remi-modular.repo
CentOS-Linux-FastTrack.repo          remi-release-8.rpm
CentOS-Linux-HighAvailability.repo   remi.repo
CentOS-Linux-Media.repo              remi-safe.repo
CentOS-Linux-Plus.repo
[root@nextcloud yum.repos.d]# vi mariadb.repo
[root@nextcloud yum.repos.d]# vi mariadb.repo

修改MariaDB.repo文件

[root@nextcloud yum.repos.d]# cat mariadb.repo
# MariaDB 10.5 CentOS repository list - created 2021-06-23 09:53 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@nextcloud yum.repos.d]#

执行安装命令

[root@nextcloud yum.repos.d]# sudo dnf install MariaDB-server
Repository extras is listed more than once in the configuration
MariaDB                                         95 kB/s | 603 kB     00:06
上次元数据过期检查:0:00:03 前,执行于 20220725日 星期一 094034秒。
依赖关系解决。
===============================================================================
 软件包               架构         版本                  仓库             大小
===============================================================================
安装:
 MariaDB-server       x86_64       10.5.16-1.el8         mariadb          26 M
安装依赖关系:
 MariaDB-client       x86_64       10.5.16-1.el8         mariadb          13 M
 galera-4             x86_64       26.4.11-1.el8         mariadb          13 M
 socat                x86_64       1.7.4.1-1.el8         AppStream       323 k
降级:
 MariaDB-common       x86_64       10.5.16-1.el8         mariadb          87 k

事务概要
===============================================================================
安装  4 软件包
降级  1 软件包

总下载:54 M
确定吗?[y/N]: y
下载软件包:
(1/5): MariaDB-common-10.5.16-1.el8.x86_64.rpm  51 kB/s |  87 kB     00:01
(2/5): socat-1.7.4.1-1.el8.x86_64.rpm          177 kB/s | 323 kB     00:01
(3/5): galera-4-26.4.11-1.el8.x86_64.rpm        86 kB/s |  13 MB     02:39
(4/5): MariaDB-client-10.5.16-1.el8.x86_64.rpm  48 kB/s |  13 MB     04:43
(5/5): MariaDB-server-10.5.16-1.el8.x86_64.rpm  46 kB/s |  26 MB     09:49
-------------------------------------------------------------------------------
总计                                            93 kB/s |  54 MB     09:51
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                1/1
  运行脚本: MariaDB-common-10.5.16-1.el8.x86_64                            1/6
  降级    : MariaDB-common-10.5.16-1.el8.x86_64                            1/6
  运行脚本: MariaDB-common-10.5.16-1.el8.x86_64                            1/6
  运行脚本: MariaDB-client-10.5.16-1.el8.x86_64                            2/6
  安装    : MariaDB-client-10.5.16-1.el8.x86_64                            2/6
  运行脚本: MariaDB-client-10.5.16-1.el8.x86_64                            2/6
  安装    : socat-1.7.4.1-1.el8.x86_64                                     3/6
  运行脚本: galera-4-26.4.11-1.el8.x86_64                                  4/6
  安装    : galera-4-26.4.11-1.el8.x86_64                                  4/6
  运行脚本: galera-4-26.4.11-1.el8.x86_64                                  4/6
  运行脚本: MariaDB-server-10.5.16-1.el8.x86_64                            5/6
  安装    : MariaDB-server-10.5.16-1.el8.x86_64                            5/6
  运行脚本: MariaDB-server-10.5.16-1.el8.x86_64                            5/6


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/


  运行脚本: MariaDB-common-10.9.1-1.el8.x86_64                             6/6
  清理    : MariaDB-common-10.9.1-1.el8.x86_64                             6/6
  运行脚本: MariaDB-common-10.9.1-1.el8.x86_64                             6/6
  运行脚本: MariaDB-server-10.5.16-1.el8.x86_64                            6/6
  运行脚本: MariaDB-common-10.9.1-1.el8.x86_64                             6/6
  验证    : MariaDB-common-10.5.16-1.el8.x86_64                            1/6
  验证    : MariaDB-common-10.9.1-1.el8.x86_64                             2/6
  验证    : socat-1.7.4.1-1.el8.x86_64                                     3/6
  验证    : MariaDB-client-10.5.16-1.el8.x86_64                            4/6
  验证    : MariaDB-server-10.5.16-1.el8.x86_64                            5/6
  验证    : galera-4-26.4.11-1.el8.x86_64                                  6/6

已降级:
  MariaDB-common-10.5.16-1.el8.x86_64
已安装:
  MariaDB-client-10.5.16-1.el8.x86_64    MariaDB-server-10.5.16-1.el8.x86_64
  galera-4-26.4.11-1.el8.x86_64          socat-1.7.4.1-1.el8.x86_64

完毕!
[root@nextcloud yum.repos.d]#


初始化MariaDB

[root@nextcloud yum.repos.d]# systemctl start mariadb.service
[root@nextcloud yum.repos.d]# systemctl enable mariadb.service
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

其他MariaDB服务管理命令:

systemctl enable mariadb.service #设置开机启动
systemctl restart mariadb.service #重新启动
systemctl status mariadb.service #查看下状态
systemctl stop mariadb.service #停止MariaDB服务
systemctl disable mariadb.service #删除MariaDB服务

初始化MariaDB配置

[root@nextcloud yum.repos.d]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y # 是否设置root用户密码,输入y并回车或直接回车
New password: # 设置root用户的密码
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y # 是否删除匿名用户,回车
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] #是否禁止root远程登录,回车,
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]  # 是否删除test数据库,回车
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]  #是否重新加载权限表,回车
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@nextcloud yum.repos.d]#

修改my.cnf字符集

[root@nextcloud etc]# cat my.cnf
#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include *.cnf from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
init_connect='SET collation_connection = utf8mb4_general_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
skip-character-set-client-handshake

增加数据库用户、数据库名

[root@nextcloud etc]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.16-MariaDB MariaDB Server

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)]> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.001 sec)

+----------------------+--------------------+
| Variable_name        | Value              |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
| collation_database   | utf8mb4_general_ci |
| collation_server     | utf8mb4_general_ci |
+----------------------+--------------------+
3 rows in set (0.001 sec)

MariaDB [(none)]> create user 'wqb'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> select user,host from mysql.user;
+-------------+-----------+
| User        | Host      |
+-------------+-----------+
| mariadb.sys | localhost |
| mysql       | localhost |
| root        | localhost |
| username    | localhost |
| wqb         | localhost |
+-------------+-----------+
5 rows in set (0.001 sec)

MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES on nextcloud.* to 'username'@'localhost';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nextcloud          |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [(none)]> use nextcloud
Database changed
MariaDB [nextcloud]> show tables;
Empty set (0.000 sec)

MariaDB [nextcloud]> quit
Bye
[root@nextcloud etc]#

www.htsjk.Com true http://www.htsjk.com/mariadb/45947.html NewsArticle CentOS8 安装 MariaDB数据库,依赖关系解决。软件包 创建MariaDB.repo文件 [ rootnextcloud etc ] # cd yum . repos . d / [ rootnextcloud yum . repos . d ] # lsCentOS - Base . repo CentOS - Linux - PowerTools . repoCentOS - Lin...
评论暂时关闭