当前位置: 首页 > news >正文

mariadb centos 7 安装

执行完: yum install mariadb


执行  systemctl start mariadb
执行  systemctl start mysql
执行  systemctl start mariadb
报类似如下错误:
Failed to start mariadb.service: Unit not found. mariadb-10.5.26 

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

期间有人提醒可能是没装mariadb server 于是执行安装

yum install mariadb-server
 
systemctl start mariadb

安装完上述命令后,出现:
# yum install mariadb-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: repo.jing.rocks
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 mariadb-server 已经被 MariaDB-server 取代,改为尝试安装 MariaDB-server-10.5.26-1.el7.centos.x86_64
正在解决依赖关系
--> 正在检查事务
---> 软件包 MariaDB-server.x86_64.0.10.5.26-1.el7.centos 将被 安装
--> 正在处理依赖关系 galera-4,它被软件包 MariaDB-server-10.5.26-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 galera-4.x86_64.0.26.4.19-1.el7.centos 将被 安装
--> 正在处理依赖关系 socat,它被软件包 galera-4-26.4.19-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 libboost_program_options-mt.so.1.53.0()(64bit),它被软件包 galera-4-26.4.19-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 boost-program-options.x86_64.0.1.53.0-28.el7 将被 安装
---> 软件包 socat.x86_64.0.1.7.3.2-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================================================
 Package                          架构              版本                               源                  大小
================================================================================================================
正在安装:
 MariaDB-server                   x86_64            10.5.26-1.el7.centos               MariaDB             26 M
为依赖而安装:
 boost-program-options            x86_64            1.53.0-28.el7                      base               156 k
 galera-4                         x86_64            26.4.19-1.el7.centos               MariaDB             10 M
 socat                            x86_64            1.7.3.2-2.el7                      base               290 k

事务概要
================================================================================================================
安装  1 软件包 (+3 依赖软件包)

总下载量:37 M
安装大小:173 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): boost-program-options-1.53.0-28.el7.x86_64.rpm                                    | 156 kB  00:00:00
(2/2): socat-1.7.3.2-2.el7.x86_64.rpm                                                    | 290 kB  00:00:02
----------------------------------------------------------------------------------------------------------------
总计                                                                             14 MB/s |  37 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : socat-1.7.3.2-2.el7.x86_64                                                                  1/4
  正在安装    : boost-program-options-1.53.0-28.el7.x86_64                                                  2/4
  正在安装    : galera-4-26.4.19-1.el7.centos.x86_64                                                        3/4
  正在安装    : MariaDB-server-10.5.26-1.el7.centos.x86_64                                                  4/4


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/

  验证中      : galera-4-26.4.19-1.el7.centos.x86_64                                                        1/4
  验证中      : boost-program-options-1.53.0-28.el7.x86_64                                                  2/4
  验证中      : MariaDB-server-10.5.26-1.el7.centos.x86_64                                                  3/4
  验证中      : socat-1.7.3.2-2.el7.x86_64                                                                  4/4

已安装:
  MariaDB-server.x86_64 0:10.5.26-1.el7.centos

作为依赖被安装:
  boost-program-options.x86_64 0:1.53.0-28.el7              galera-4.x86_64 0:26.4.19-1.el7.centos
  socat.x86_64 0:1.7.3.2-2.el7

完毕!
root@PPNginx-P01: /opt 16:41:12
# systemctl start mariadb
root@PPNginx-P01: /opt 16:41:24

# mysql -h 127.0.0.1   首次访问用网络的形式,不行,下面用本地登录形式访问
ERROR 1698 (28000): Access denied for user 'root'@'localhost'    
root@PPNginx-P01: /opt 16:56:28
# mysql -h localhost
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.26-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)]>
 

MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> use mariadb
ERROR 1049 (42000): Unknown database 'mariadb'
MariaDB [mysql]> update mysql.user set password = PASSWORD('Hello@123') WHERE user = 'root';
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
MariaDB [mysql]> set password=PASSWORD('Hello@12367892');
Query OK, 0 rows affected (0.003 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [mysql]>


远程连接连不上报:

host is not allowed to connect to this mariadb server

可以执行这个:

GRANT ALL PRIVILEGES ON database_name.* TO 'root'@'%' IDENTIFIED BY 'Hello@12345679';

更改端口:
 

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
port=3307
# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

"server.cnf" 46L, 1089C       

防火墙类:
 

开启防火墙:

sudo systemctl start firewalld

关闭防火墙:

sudo systemctl stop firewalld

查看防火墙状态

sudo systemctl status firewalld

开机自启:

sudo systemctl enable firewalld

开机禁用:

sudo systemctl disable firewalld

添加规则允许某个服务(如 http)通过防火墙:

sudo firewall-cmd --zone=public --add-service=http --permanent

允许某个端口

sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent

允许某个端口

firewall-cmd --zone=public --remove-port=8080/tcp --permanent

重新加载防火墙策略

sudo firewall-cmd --reload

查看当前防火墙策略:

sudo firewall-cmd --list-all

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 百数功能插件技术解析:审批流程设置与数据填写便捷性探讨
  • 《Programming from the Ground Up》阅读笔记:p95-p102
  • Redis使用详解
  • LLM之基于llama-index部署本地embedding与GLM-4模型并初步搭建RAG(其他大模型也可,附上ollma方式运行)
  • 【设计模式】模板方法模式和迭代器模式
  • 【Docker】Linux系统以及威联通QNAP部署思源笔记的通用教程
  • css实现闪烁渐变背景,@property自定义属性
  • 一次了解所有功能!超详细【Stable Diffusion界面】大揭秘!
  • 简过网:报个线上公务员培训班大概要多少钱?
  • 警惕!低血糖来袭,这些“隐形信号”你中招了吗?
  • 解决LabVIEW配置文件中文乱码问题
  • 【项目】微服务及时通讯系统:编写核心类
  • 拼车系统开发方案
  • Android about event log
  • 《通义千问AI落地—中》:前端实现
  • JS中 map, filter, some, every, forEach, for in, for of 用法总结
  • 【RocksDB】TransactionDB源码分析
  • 78. Subsets
  • AzureCon上微软宣布了哪些容器相关的重磅消息
  • co模块的前端实现
  • fetch 从初识到应用
  • flask接收请求并推入栈
  • JavaScript 事件——“事件类型”中“HTML5事件”的注意要点
  • Java读取Properties文件的六种方法
  • learning koa2.x
  • SpingCloudBus整合RabbitMQ
  • Vue 2.3、2.4 知识点小结
  • 面试总结JavaScript篇
  • 前端每日实战:70# 视频演示如何用纯 CSS 创作一只徘徊的果冻怪兽
  • 前言-如何学习区块链
  • 山寨一个 Promise
  • 终端用户监控:真实用户监控还是模拟监控?
  • media数据库操作,可以进行增删改查,实现回收站,隐私照片功能 SharedPreferences存储地址:
  • JavaScript 新语法详解:Class 的私有属性与私有方法 ...
  • 东超科技获得千万级Pre-A轮融资,投资方为中科创星 ...
  • 如何正确理解,内页权重高于首页?
  • ​​​​​​​​​​​​​​Γ函数
  • ​LeetCode解法汇总1276. 不浪费原料的汉堡制作方案
  • # Swust 12th acm 邀请赛# [ E ] 01 String [题解]
  • #define,static,const,三种常量的区别
  • #Linux(Source Insight安装及工程建立)
  • #vue3 实现前端下载excel文件模板功能
  • (2009.11版)《网络管理员考试 考前冲刺预测卷及考点解析》复习重点
  • (博弈 sg入门)kiki's game -- hdu -- 2147
  • (附源码)spring boot智能服药提醒app 毕业设计 102151
  • (附源码)springboot社区居家养老互助服务管理平台 毕业设计 062027
  • (附源码)计算机毕业设计SSM在线影视购票系统
  • (十五)devops持续集成开发——jenkins流水线构建策略配置及触发器的使用
  • (四)Android布局类型(线性布局LinearLayout)
  • (四)软件性能测试
  • (一)spring cloud微服务分布式云架构 - Spring Cloud简介
  • (转载)OpenStack Hacker养成指南
  • .NET Core 成都线下面基会拉开序幕
  • .net core 的缓存方案
  • .NET Core6.0 MVC+layui+SqlSugar 简单增删改查