一、检查系统版本
[root@serer01 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
二、配置mariadb的yum源
1.配置yum源
[root@serer01 ~]# cat /etc/yum.repos.d/mariadb.repo
# MariaDB 10.6 CentOS repository list - created 2021-12-27 11:21 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.xtom.com.hk/mariadb/yum/10.6/centos7-amd64
gpgkey=https://mirrors.xtom.com.hk/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=0
enable=1
2.替换中科大的源
sed -i 's#//mirrors.xtom.com.hk#//mirrors.ustc.edu.cn#g' /etc/yum.repos.d/mariadb.repo
三、检查yum仓库
1.修改/etc/yum.conf文件
[root@serer01 ~]# grep false /etc/yum.conf
sslverify=false
2.检查yum仓库
[root@serer01 ~]# yum repolist all |grep enable
base/7/x86_64 CentOS-7 - Base - mirrors.a enabled: 10,072
docker-ce-stable/7/x86_64 Docker CE Stable - x86_64 enabled: 183
extras/7/x86_64 CentOS-7 - Extras - mirrors enabled: 515
mariadb MariaDB enabled: 95
updates/7/x86_64 CentOS-7 - Updates - mirror enabled: 4,346
四、安装mariadb
[root@serer01 ~]# yum -y install Mariadb-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package Mariadb-server available.
* Maybe you meant: MariaDB-server, mariadb-server
Error: Nothing to do
[root@serer01 ~]# yum -y install Mariadb-server --nodeps
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package Mariadb-server available.
* Maybe you meant: MariaDB-server, mariadb-server
Error: Nothing to do
[root@serer01 ~]# yum -y install MariaDB-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-server.x86_64 0:10.6.10-1.el7.centos will be installed
--> Processing Dependency: MariaDB-common >= 10.6.1 for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: MariaDB-client >= 10.6.1 for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: libpmem.so.1(LIBPMEM_1.0)(64bit) for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: rsync for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: galera-4 for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: lsof for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: libpmem.so.1()(64bit) for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: libpcre2-8.so.0()(64bit) for package: MariaDB-server-10.6.10-1.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.6.10-1.el7.centos will be installed
--> Processing Dependency: perl(DBI) for package: MariaDB-client-10.6.10-1.el7.centos.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: MariaDB-client-10.6.10-1.el7.centos.x86_64
---> Package MariaDB-common.x86_64 0:10.6.10-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.6.10-1.el7.centos.x86_64
---> Package galera-4.x86_64 0:26.4.12-1.el7.centos will be installed
--> Processing Dependency: socat for package: galera-4-26.4.12-1.el7.centos.x86_64
--> Processing Dependency: libboost_program_options-mt.so.1.53.0()(64bit) for package: galera-4-26.4.12-1.el7.centos.x86_64
---> Package libpmem.x86_64 0:1.5.1-2.1.el7 will be installed
---> Package lsof.x86_64 0:4.87-6.el7 will be installed
---> Package openssl-libs.x86_64 1:1.0.1e-42.el7.9 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-42.el7.9 for package: 1:openssl-1.0.1e-42.el7.9.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-25.el7_9 will be an update
---> Package pcre2.x86_64 0:10.23-2.el7 will be installed
---> Package rsync.x86_64 0:3.1.2-11.el7_9 will be installed
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.6.10-1.el7.centos will be obsoleting
---> Package boost-program-options.x86_64 0:1.53.0-28.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
---> Package openssl.x86_64 1:1.0.1e-42.el7.9 will be updated
---> Package openssl.x86_64 1:1.0.2k-25.el7_9 will be an update
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed
--> Running transaction check
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================
Installing:
MariaDB-compat x86_64 10.6.10-1.el7.centos mariadb 2.2 M
replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
MariaDB-server x86_64 10.6.10-1.el7.centos mariadb 25 M
Installing for dependencies:
MariaDB-client x86_64 10.6.10-1.el7.centos mariadb 14 M
MariaDB-common x86_64 10.6.10-1.el7.centos mariadb 81 k
boost-program-options x86_64 1.53.0-28.el7 base 156 k
galera-4 x86_64 26.4.12-1.el7.centos mariadb 9.9 M
libpmem x86_64 1.5.1-2.1.el7 base 59 k
lsof x86_64 4.87-6.el7 base 331 k
pcre2 x86_64 10.23-2.el7 base 201 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
rsync x86_64 3.1.2-11.el7_9 updates 408 k
socat x86_64 1.7.3.2-2.el7 base 290 k
Updating for dependencies:
openssl x86_64 1:1.0.2k-25.el7_9 updates 494 k
openssl-libs x86_64 1:1.0.2k-25.el7_9 updates 1.2 M
Transaction Summary
===================================================================================================================================================
Install 2 Packages (+16 Dependent packages)
Upgrade ( 2 Dependent packages)
Total download size: 56 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/20): MariaDB-common-10.6.10-1.el7.centos.x86_64.rpm | 81 kB 00:00:00
(2/20): MariaDB-compat-10.6.10-1.el7.centos.x86_64.rpm | 2.2 MB 00:00:00
(3/20): MariaDB-client-10.6.10-1.el7.centos.x86_64.rpm | 14 MB 00:00:01
(4/20): boost-program-options-1.53.0-28.el7.x86_64.rpm | 156 kB 00:00:00
(5/20): libpmem-1.5.1-2.1.el7.x86_64.rpm | 59 kB 00:00:00
(6/20): openssl-1.0.2k-25.el7_9.x86_64.rpm | 494 kB 00:00:00
(7/20): pcre2-10.23-2.el7.x86_64.rpm | 201 kB 00:00:00
(8/20): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(9/20): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(10/20): openssl-libs-1.0.2k-25.el7_9.x86_64.rpm | 1.2 MB 00:00:00
(11/20): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(12/20): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(13/20): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
(14/20): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(15/20): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(16/20): socat-1.7.3.2-2.el7.x86_64.rpm | 290 kB 00:00:00
(17/20): lsof-4.87-6.el7.x86_64.rpm | 331 kB 00:00:00
(18/20): rsync-3.1.2-11.el7_9.x86_64.rpm | 408 kB 00:00:00
(19/20): MariaDB-server-10.6.10-1.el7.centos.x86_64.rpm | 25 MB 00:00:02
(20/20): galera-4-26.4.12-1.el7.centos.x86_64.rpm | 9.9 MB 00:00:01
---------------------------------------------------------------------------------------------------------------------------------------------------
Total 19 MB/s | 56 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 1:openssl-libs-1.0.2k-25.el7_9.x86_64 1/23
Installing : pcre2-10.23-2.el7.x86_64 2/23
Installing : libpmem-1.5.1-2.1.el7.x86_64 3/23
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 4/23
Installing : rsync-3.1.2-11.el7_9.x86_64 5/23
Installing : lsof-4.87-6.el7.x86_64 6/23
Updating : 1:openssl-1.0.2k-25.el7_9.x86_64 7/23
Installing : MariaDB-common-10.6.10-1.el7.centos.x86_64 8/23
Installing : MariaDB-compat-10.6.10-1.el7.centos.x86_64 9/23
Installing : socat-1.7.3.2-2.el7.x86_64 10/23
Installing : perl-Net-Daemon-0.48-5.el7.noarch 11/23
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 12/23
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 13/23
Installing : perl-IO-Compress-2.061-2.el7.noarch 14/23
Installing : perl-PlRPC-0.2020-14.el7.noarch 15/23
Installing : perl-DBI-1.627-4.el7.x86_64 16/23
Installing : MariaDB-client-10.6.10-1.el7.centos.x86_64 17/23
Installing : boost-program-options-1.53.0-28.el7.x86_64 18/23
Installing : galera-4-26.4.12-1.el7.centos.x86_64 19/23
Installing : MariaDB-server-10.6.10-1.el7.centos.x86_64 20/23
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/
Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 21/23
Cleanup : 1:openssl-1.0.1e-42.el7.9.x86_64 22/23
Cleanup : 1:openssl-libs-1.0.1e-42.el7.9.x86_64 23/23
Verifying : boost-program-options-1.53.0-28.el7.x86_64 1/23
Verifying : 1:openssl-1.0.2k-25.el7_9.x86_64 2/23
Verifying : lsof-4.87-6.el7.x86_64 3/23
Verifying : MariaDB-server-10.6.10-1.el7.centos.x86_64 4/23
Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 5/23
Verifying : rsync-3.1.2-11.el7_9.x86_64 6/23
Verifying : MariaDB-compat-10.6.10-1.el7.centos.x86_64 7/23
Verifying : MariaDB-client-10.6.10-1.el7.centos.x86_64 8/23
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 9/23
Verifying : perl-DBI-1.627-4.el7.x86_64 10/23
Verifying : libpmem-1.5.1-2.1.el7.x86_64 11/23
Verifying : pcre2-10.23-2.el7.x86_64 12/23
Verifying : galera-4-26.4.12-1.el7.centos.x86_64 13/23
Verifying : 1:openssl-libs-1.0.2k-25.el7_9.x86_64 14/23
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 15/23
Verifying : perl-Net-Daemon-0.48-5.el7.noarch 16/23
Verifying : perl-IO-Compress-2.061-2.el7.noarch 17/23
Verifying : perl-PlRPC-0.2020-14.el7.noarch 18/23
Verifying : MariaDB-common-10.6.10-1.el7.centos.x86_64 19/23
Verifying : socat-1.7.3.2-2.el7.x86_64 20/23
Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 21/23
Verifying : 1:openssl-libs-1.0.1e-42.el7.9.x86_64 22/23
Verifying : 1:openssl-1.0.1e-42.el7.9.x86_64 23/23
Installed:
MariaDB-compat.x86_64 0:10.6.10-1.el7.centos MariaDB-server.x86_64 0:10.6.10-1.el7.centos
Dependency Installed:
MariaDB-client.x86_64 0:10.6.10-1.el7.centos MariaDB-common.x86_64 0:10.6.10-1.el7.centos boost-program-options.x86_64 0:1.53.0-28.el7
galera-4.x86_64 0:26.4.12-1.el7.centos libpmem.x86_64 0:1.5.1-2.1.el7 lsof.x86_64 0:4.87-6.el7
pcre2.x86_64 0:10.23-2.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 rsync.x86_64 0:3.1.2-11.el7_9
socat.x86_64 0:1.7.3.2-2.el7
Dependency Updated:
openssl.x86_64 1:1.0.2k-25.el7_9 openssl-libs.x86_64 1:1.0.2k-25.el7_9
Replaced:
mariadb-libs.x86_64 1:5.5.44-2.el7.centos
Complete!
五、启动mariadb服务
1.启动mariadb服务
[root@serer01 ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
2.查看mariadb服务状态
[root@serer01 ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.6.10 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Fri 2022-11-04 22:50:42 CST; 38s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 13728 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 13702 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 13700 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 13714 (mariadbd)
Status: "Taking your SQL requests now..."
Memory: 61.3M
CGroup: /system.slice/mariadb.service
└─13714 /usr/sbin/mariadbd
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] InnoDB: 10.6.10 started; log sequence number 42132; transaction id 14
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] Plugin 'FEEDBACK' is disabled.
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] InnoDB: Buffer pool(s) load completed at 221104 22:50:42
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] Server socket created on IP: '0.0.0.0'.
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] Server socket created on IP: '::'.
Nov 04 22:50:42 serer01 mariadbd[13714]: 2022-11-04 22:50:42 0 [Note] /usr/sbin/mariadbd: ready for connections.
Nov 04 22:50:42 serer01 mariadbd[13714]: Version: '10.6.10-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
Nov 04 22:50:42 serer01 systemd[1]: Started MariaDB 10.6.10 database server.
六、mariadb的远程连接
1.本地连接
[root@serer01 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 3
Server version: 10.6.10-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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.002 sec)
MariaDB [(none)]>
2.创建用户
MariaDB [(none)]> CREATE USER 'admin'@'%' IDENTIFIED BY 'admin123456';
Query OK, 0 rows affected (0.021 sec)
MariaDB [(none)]>
3.对用户授权
MariaDB [(none)]> grant all on *.* to 'admin'@'%' with grant option;
Query OK, 0 rows affected (0.020 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]>
4.测试远程连接mariadb数据库
[root@serer01 ~]# mysql -h 192.168.3.169 -P3306 -uadmin -padmin123456
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 5
Server version: 10.6.10-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)]>
原文地址:https://blog.csdn.net/jks212454/article/details/128456504
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_36868.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。