【安装】Linux Centos 或 Debian 离线安装指定版本MariaDB

【安装】Linux Centos 或 Debian 离线安装指定版本MariaDB

下载地址

https://mariadb.com/downloads/community/community-server/https://mirrors.aliyun.com/mariadb/yum/https://mariadb.com/downloads/community/community-server/

Download MariaDB Server - MariaDB.org

mariadb-yum安装包下载_开源镜像站-阿里云

1. 下载安装包

centos

mariadb-11.4.2-rhel-7-x86_64-rpms.tar

wget https://dlm.mariadb.com/3827291/MariaDB/mariadb-11.4.2/yum/centos/mariadb-11.4.2-rhel-7-x86_64-rpms.tar

Debian

选择对应的 Debian版本

mariadb-11.4.2-debian-bookworm-amd64-debs.tar

wget https://dlm.mariadb.com/3825286/MariaDB/mariadb-11.4.2/repo/debian/mariadb-11.4.2-debian-bookworm-amd64-debs.tar

2.解压

tar -xvf mariadb-11.4.2-rhel-7-x86_64-rpms.tar

3.进入该目录

cd mariadb-11.4.2-rhel-7-x86_64-rpms/

4.执行 ./setup_repository

./setup_repository

5.安装MariaDB

Centos安装命令 

yum -y install MariaDB-server

debian 安装命令

apt install mariadb-server

安装成功 

启动服务

sudo systemctl start mariadb

配置安全控制程序

mariadb-secure-installation

输入当前 root 密码,因为当前密码为空,直接回车

是否设置 root 密码,这里输入 y 表示设置密码,输入2次密码,显示 success 为成功

是否删除匿名用户,选择删除

是否禁止 root 用户远程登录数据库,设置为是

是否删除test数据库,这里为了后面测试选择不删除

是否重载授权表,选择是

重启服务

sudo systemctl restart mariadb

停止服务

sudo systemctl stop mariadb

允许远程访问

/etc/mysql/mariadb.conf.d

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0

默认root账号只支持本地访问

在MariaDB中创建一个新用户,并为这个用户授权。

在MariaDB命令行终端中执行以下命令:

CREATE USER '用户名'@'%' IDENTIFIED BY '密码'; GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;

默认安装目录

/usr/share/mariadb/

准备工作

1.启动服务

2.修改root密码

mysqladmin -u root -p password 新密码

刚开始没密码 所以直接两个回车就行

3.修改root外网可以访问

遇到的问题

库没了 只能看到这两个库了

原因是没权限 

修改配置文件

/etc/my.cnf.d/server.cnf

[mysqld]
skip-grant-tables

然后重启服务

 屏蔽密码登录

>mysql -uroot  -p

> use mysql;

>create user 'root'@'localhost';

 ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement

报错,输入命令刷新即可

>flush privileges ;

>create user 'root'@'localhost';

# 赋予所有权限 并且修改root密码为123456

>grant all privileges on *.* to 'root'@'localhost' identified by '123456' with grant option; 

>flush privileges ;

查看数据库当前状态

systemctl status mysqld  
# 或 
service mysqld status

后续如果需要升级的话 可以参考这篇文章

【运维】Linux 离线升级指定版本的MariaDB-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我是Superman丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值