当前位置:网站首页>MariaDB的安装与配置
MariaDB的安装与配置
2022-07-06 09:28:00 【萌褚】
镜像下载、域名解析、时间同步请点击 阿里云开源镜像站
MariaDB的安装与配置
(菜鸡我是用阿里源安装的)
MariaDB是MySQL的一个分支,由开源社区维护,采用GPL授权许可,完全兼容MySQL.
1.安装相对应的源
vi /etc/yum.repos.d/MariaDB.repo
# 填写如下内容(3选其一,我选择的是阿里源)
[mariadb]
# http://downloads.mariadb.org/mariadb/repositories/(官方源5.5)
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[mariadb]
# 官方源10.1
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[mariadb]
# 阿里的源10.4
name = MariaDB
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.4/centos7-amd64/
gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
保存,退出
2.清除缓存,加载配置
yum clean all
yum makecache
3.安装mariadb
(阿里源的mariadb包名是小写的,而官方源是大写的)
# 官方:
yum install -y MariaDB-server MariaDB-client
# 阿里:
yum install -y mariadb-server mariadb
4.启动mariadb
systemctl start mariadb
4-1.相关MariaDB管理命令
# 重启
systemctl restart mariadb
# 停止
systemctl stop mariadb
# 开机自启
systemctl enable mariadb
5. 查看mariadb进程
netstat -ntlp | grep 3306
或
netstat -ntlp | grep mysql
6.MariaDB数据库初始化
mysql_secure_installation
7.初始化测试登陆
mysql -uroot -p #进入数据库
8.MariaDB设置utf8编码(根据实际需求添加)
vi /etc/my.cnf
#输入以下内容:
[mysqld]
character-set-server=utf8
init-connect='SET NAMES utf8'
collation-server=utf8_unicode_ci
9.MariaDB的简单使用
1)修改密码
set password = PASSWORD('[email protected]'); # 设置密码为[email protected]
2)mysql常用命令(部分)
desc 表名 # 查看表结构
create database 数据库名; # 创建数据库
create table 表名; # 创建数据表
drop database 数据库名; # 删除数据库
show create database 数据库库名; # 查看如何创建数据库
show create table 表名; # 查看如何创建表
10.MariaDB数据库备份与恢复
具体步骤:备份,恢复
前置条件
create database one;
create database two;
show databases;
\q #退出mysql
mkdir -p /tmp/mysqld
cd /tmp/mysqld
rm -rf *
根据自己需求进行选择
1-1)备份所有的数据库
mysqldump -u root -p --all-databases > /tmp/mysqld/db.dump #备份所有的数据库
#输入密码
ls #就可以查看到新增了db.dump文件(这就是数据库备份的文件).
1-2)备份单个数据库
mysqldump -u root -p one > /tmp/mysqld/one.dump #备份名为one的数据库
#输入密码
ls #就看到新增了one.dump文件.
2),进入到MariaDB,删除数据库,并查看结果
mysql -uroot -p
# 输入密码
drop database one;
drop database one;
根据自己需求进行选择
3-1)恢复所有数据库
mysql -uroot -p < /tmp/mysqld/db.dump
3-2)恢复名为one的数据库
mysql -uroot -p < /tmp/mysqld/one.dump
原文链接:https://blog.csdn.net/weixin_51202460/article/details/123672061
边栏推荐
- Understand what is a programming language in a popular way
- 生成随机密码/验证码
- Determine the Photo Position
- The "sneaky" new asteroid will pass the earth safely this week: how to watch it
- Luogu P1102 A-B number pair (dichotomy, map, double pointer)
- C basic grammar
- 日期加1天
- [exercise-6] (PTA) divide and conquer
- Codeforces Round #799 (Div. 4)A~H
- Codeforces Round #803 (Div. 2)A~C
猜你喜欢
Share an example of running dash application in raspberry pie.
(POJ - 3685) matrix (two sets and two parts)
Advancedinstaller安装包自定义操作打开文件
antd upload beforeUpload中禁止触发onchange
It is forbidden to trigger onchange in antd upload beforeupload
Penetration test (3) -- Metasploit framework (MSF)
Analysis of protobuf format of real-time barrage and historical barrage at station B
1903. Maximum odd number in string
[exercise-7] crossover answers
浏览器打印边距,默认/无边距,占满1页A4
随机推荐
HDU - 6024 building shops (girls' competition)
input 只能输入数字,限定输入
Share an example of running dash application in raspberry pie.
Sword finger offer II 019 Delete at most one character to get a palindrome
[exercise-3] (UVA 442) matrix chain multiplication
Codeforces Round #798 (Div. 2)A~D
860. Lemonade change
Configuration du cadre flask loguru log Library
顺丰科技智慧物流校园技术挑战赛(无t4)
Understand what is a programming language in a popular way
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
拉取分支失败,fatal: ‘origin/xxx‘ is not a commit and a branch ‘xxx‘ cannot be created from it
MySQL grants the user the operation permission of the specified content
浏览器打印边距,默认/无边距,占满1页A4
Penetration test (8) -- official document of burp Suite Pro
C basic grammar
Find 3-friendly Integers
(POJ - 3579) median (two points)
628. Maximum product of three numbers
Ball Dropping