创建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 前,执行于 2022年07月25日 星期一 09时40分34秒。
依赖关系解决。
===============================================================================软件包               架构         版本                  仓库             大小
===============================================================================
安装:MariaDB-server       x86_64       10.5.16-1.el8         mariadb          26 M
安装依赖关系:MariaDB-client       x86_64       10.5.16-1.el8         mariadb          13 Mgalera-4             x86_64       26.4.11-1.el8         mariadb          13 Msocat                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/6Two 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 sudoSee the MariaDB Knowledgebase at https://mariadb.com/kbPlease report any problems at https://mariadb.org/jiraThe 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_64galera-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_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS 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 ServerCopyright (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]#

CentOS8 安装 MariaDB数据库相关推荐

  1. Windows 中安装 MariaDB 数据库

    mariadb 在 Windows 下的安装非常简单,下载程序双击运行就可以了. 需要注意: mariadb 和 MySQL 数据库在 Windows 下默认是不区分大小写的,但是在 Linux 下是 ...

  2. mac系统装mysql还是mariadb_Mac安装MariaDB数据库

    Mac安装MariaDB数据库 参考资料: 如果你是Mac上的开发者,你可以在OS X上通过Homebrew来简单的获取安装最新稳定版本的MariaDB,接下来我们将一步步的来指导安装MariaDB数 ...

  3. 在Linux虚拟机安装MariaDB数据库

    1. 下载MariaDB数据库 测试: 当前虚拟机是否可以正确的链接外网. 命令: [root@localhost src]# yum install mariadb-server 安装mariadb ...

  4. linux安装mariadb数据库

    1. 安装mariadb数据库 1. 在linux系统安装mariadb数据库 命令: yum install mariadb-server -- 安装mariadb数据库 如果安装失败执行此命令: ...

  5. 树莓派无法安装mariadb_RaspberryPi(树莓派)安装 MariaDB 数据库没有办法远程访问...

    在 RaspberryPi(树莓派) 上安装 MariaDB  或者 MySQL 数据库的时候. 设置的用户没有办法通过网络远程登录. 首先确定的是,用户已经设置了访问权限. 提示的错误信息是: ER ...

  6. Fedora安装Mariadb数据库

    据说mariaDB是fedora的默认数据库,但是我用的ive安装的fedora20似乎没有找到数据库的影子,新手新手... 所以写个博客记录一下怎么安的吧! 首先,我试了一下,直接在终端下 yum ...

  7. 安装MariaDB数据库(未完成)

    1 转载于:https://www.cnblogs.com/centos7/p/5994533.html

  8. mysql数据库源码安装_学习笔记-源码安装mariadb 20210128

    源码安装Mariadb数据库 安装之前先检查一下空间: 1 [15:13:16 root@centos8 ~]#free -h(#检查空间)2 total used free shared buff/ ...

  9. 树莓派无法安装mariadb_RaspberryPi(树莓派)如何安装 MariaDB / MySQL 数据库

    安装的过程比较简单. 但是这里有一个地方需要注意,如果你希望是能够通过网络访问你安装的数据库的话. 在你设置好用户名和密码,以及访问权限后,你可能发现你还是访问不了. 这是因为你的安装服务器只绑定了能 ...

最新文章

  1. 单目3D人脸重建DECA
  2. Apache 的管理及优化web
  3. 检查你的项目的引用包依赖关系
  4. python是动态_1.2. Python是动态语言
  5. OleDbCommandBuilder 使用方法
  6. ps aux 和ps -aux和 ps -ef的选择
  7. 传输层协议(13):拥塞控制(2)
  8. ROS机器人语音交互(一)
  9. 美团设计模式在外卖营销业务中的实践-学习笔记(一)
  10. Android 显示文字超过指定长度部分使用省略号表示
  11. 《动手学深度学习》(PyTorch版)代码注释 - 3 【Softmaxs_regression_with_zero】
  12. 泰然金融牵手快公益 花儿计划国学课入畲乡
  13. CUDA——线程束分化
  14. SpringCloud的各种超时时间配置效果
  15. 网站在线监控工具Statping
  16. 两数相除,如果有余数则结果加一
  17. socket通信之listen函数
  18. css3小狗滑滑梯动画js特效
  19. c语言指针存储的第一个字节,c语言指针详解,学霸课堂记录
  20. 四,微服务容错Resilience4j(待改)

热门文章

  1. 采宝支付携手 - 打造O2O支付全新生态
  2. 解决:hadoop2.5.2 HA启动时出现了两个standy的Namenode,没有出现active的Namenode
  3. app mysql数据库设计_知到APPMySQL数据库设计与应用选修课答案
  4. 细数后台开发的技术栈
  5. LOTO示波器 软件功能 井字测量光标的锁定功能用于跨屏幕测量
  6. android 页面退出动画,android Activity打开和关闭动画
  7. 【C语言】团体程序设计天梯赛-练习集 L1-002 打印沙漏
  8. 程序员!逆袭参加国际马拉松!
  9. Java后端笔记_Set集合
  10. 河南大学计算机论文,河南大学本科毕业论文.doc