yum安装Mariadb,二进制安装Mariadb

yum安装Mariadb

设置Mariadb的yum源

vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name=mariadb
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.2/centos7-amd64/
gpgcheck=0

使用清华yum源安装Mariadb,可以选择不同的版本,此处安装10.2.23
yum install mariadb-server

二进制安装Mariadb

1 准备mysql用户和组

groupadd -r -g 336 mysql      #创建mysql组
useradd -r -g mysql -u 336 -s /sbin/nologin -d /data/mysql mysql  #创建mysql用户,并加入mysql用户组,设置UID为336,设置默认shell为nologoin,家目录为/data/mysql 但不自动创建

2 准备二进制程序文件和相关文件属性

tar xvf mariadb-10.2.23-linux-x86_64.tar.gz -C /usr/local   #只能放在此目录中
cd /usr/local/
ln -s mariadb-10.2.23-linux-x86_64/ mysql                   #建立软件链接,方便使用
chown -R root.root /usr/local/mysql/                        #设置属主和属组为root用户和root组

3 PATH变量

vim /etc/profile.d/mysql.sh
PATH=/usr/local/mysql/bin:$PATH
. /etc/profile.d/mysql.sh

4 准备数据库数据目录和数据(使用逻辑卷)

创建逻辑卷
pvcreate /dev/sda6
创建卷组
vgcreate vg0 /dev/sda6
创建逻辑卷
lvcreate -n mysql -L 20G /dev/vg0
创建文件系统并挂载到/data/mysql
mkfs.xfs /dev/vg0/mysql
mkdir /data/mysql
mount /dev/vg0/mysql /data/mysql
chown mysql.mysql /data/mysql/
cd /usr/local/mysql
./scripts/mysql_install_db --datadir=/data/mysql --user=mysql #安装mysql到/data/mysql目录下,用户为mysql

5 准备Mysql的服务器端配置文件

mkdir /etc/mysql
cp /usr/local/mysql/support-files/my-huge.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
[mysqld]
datadir=/data/mysql   #设置目录为/data/mysql

6 准备服务启动脚本

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
systemctl start mysqld

7 安全加固

[[email protected] ~]#/usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS 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
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y     #设置root用户密码
New password:                  #新密码
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] y  #禁止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] y    #删除测试数据库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] y  #重新加载权限表
 ... 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!

8 测试连接
mysql -uroot -pPASSWORD

原文地址:https://blog.51cto.com/13749470/2385769

时间: 2024-08-08 22:31:54

yum安装Mariadb,二进制安装Mariadb的相关文章

MariaDB二进制安装及基本管理

本文旨在复习MariaDB二进制安装以及基本管理 基础知识 1.MariaDB是MySQL原作者新作,开源社区维护,功能特性相较MySQL至少持平: 2.采用新引擎XtraDB替代MySQL的InnoDB,较早版本5.1上的MySQL默认存储引擎是MyISAM: 3.Xtradb在多核CPU上面的性能和伸缩性要更好:对于内存的分配和使用也要更好:也解除了InnoDB的很多限制:提供了比InnoDB更多的配置和性能监控参数. 4.数据库备份常有冷备.温备.热备,M有ISAM是不支持热备的,应该被淘

lnmp-----mysql安装----myql二进制安装

mysql 二进制安装,仅需要解压就可以,不需要  cmake/configure,make,make install [[email protected] tools]# pwd/home/yang/tools [[email protected] tools]# groupadd mysql[[email protected] tools]# useradd -s /sbin/nologin -g mysql -M mysql 1.采用二进制方式安装MySQL [[email protect

编译安装和二进制安装mysql

useradd -r -s /sbin/nologin -M  mysql mkdir -p /opt/data/var yum -y install make gcc-c++ cmake bison-devel  ncurses-devel /etc/init.d/iptables stop chkconfig iptables off sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config yum -y inst

rpm安装和二进制安装

rpm包安装 Tomcat RPM安装(先安装JDK + 再安装Tomcat) 1:升级系统自带的JDK(也可以使用oracle的JDK) yum install -y java-1.8.0-openjdk-devel 2:由于Java开发的程序都需要运行在Java环境,因此一般只要是Java开发的程序,在安装JDK的同时,也需要将Java虚拟机导出到环境变量JAVA_HOME中,Java的虚拟机程序:/usr/bin/java vi /etc/profile.d/java.sh 添加 expo

LAMP环境部署:Apache源码安装+MySQL二进制安装+PHP源码安装+Nginx源码安装

Apache 版本:2.2.27 MySQL 版本:5.5.54-linux2.6-x86_64PHP 版本:5.3.27一.源码安装Apache1.首先安装上传工具2.上传LAMP环境所需安装包3.解压所有安装包4.安装Apache依赖包5.创建安装目录6.配置安装文件./configure \ #./configure 是用来生成Makefile文件用于编译安装 --prefix=/application/apache-2.2.27 \ #指定安装目录--enable-deflate \ #

MySQl编译安装与二进制安装介绍

MySQL介绍 官方站点:http://www.mysql.com/ MySQL是一个开放源码的小型关联式数据库管理系统.目前MySQL被广泛地应用在Internet上的中小型网站中.由于其体积小.速度快.总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库. MySQl数据库分类 1)社区版 2)商业版 3)cluster集群 编译安装 1)编译安装 MySQL 8.0 正式版 8.0.11 已发布,官方表示 MySQL 8 要比 My

MySQL 安装(二进制安装模式)

上一篇:MySQL 安装(RPM安装模式)及目录结构 本篇使用二进制模式安装: 查看当前是几位系统:file/sbin/init 各下载地址: Mysql官网下载: http://dev.mysql.com/downloads/mysql/ (默认选择当前系统) http://dev.mysql.com/downloads/mirrors.html  (其他镜像地址) Oracle官方下载:https://edelivery.oracle.com/ FTP下载: http://ftp.iij.a

CentOS7安装通用二进制格式MariaDB 10.2.8

什么是MariaDB MariaDB 是MySql的一个分支. 了解一下数据库的发展历史,我们知道,MySql数据库不但二次易主,而且还被打入了冷宫(先被sun收购,然后sun被Oracle收购).因为Oracle有自己的数据库,同时只有Oracle自己的员工可以进行MySql的研发,所以MySQL之父Widenius先生离开了Sun之后,觉得依靠Sun/Oracle来发展MySQL,实在很不靠谱,于是决定另开分支,这个分支的名字叫做MariaDB. MariaDB不仅仅是Mysql的一个替代品

SHELL脚本之自动化安装通用二进制格式MariaDB

#!/bin/bash datadir="/mydata/data" sqlconf=/etc/mysql installdir=/usr/local/mysql # 关于安装包大家可以去官网下载,注意下载通用二进制格式的 ,然后放在ftp服务器上即可 # 此处假设我把mariadb5.5的安装包放在了ftp上的/pub/Sources/6.x86_64/mariadb下面 case $1 in 36) package=mariadb-5.5.36-linux-x86_64.tar.g