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

  • 13
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值