mariadb
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,使用XtraDB来代替MySQL的InnoDB。 MariaDB由MySQL的创始人Michael Widenius主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自Michael Widenius的女儿Maria的名字。
download mariadb
mariadb | mariadb(RPM) | 文档 |
download | 官网 | 参考 参考 |
Linux 各系统下载使用参考
Red Hat | Rocky Linux | Oracle Linux | AlmaLinux | ubuntu | suselinux | esxi | RHEL标准安装 | 系统安装参考 | YUM参考 | MobaXterm 远程连接工具 | Red Hat Enterprise 9.0 文档 | Kickstart 生成器 | |||||
download | download | download | download | download | download | download | 参考 | 参考 | 配置参考 | download | 参考 | Kickstart | |||||
版本兼容性 |
mariadb 10.11 一键自动化部署编写
- 最终实现在线下载mariadb二进制包,安装依赖,环境变量设置,初始化数据库,创建库,创建用户,创建用户权限,远程连接设置,版本获取,安装完成删除包,防火墙设置。
- /usr/local/mysql 安装位置
- /usr/local/mysql/data 数据目录
- linux 系统创建的mariadb 是mysql
- root/Report@123 mariadb数据库登录管理员
- mar/Report@123 此账号是自定义创建的管理员,生产环境删除哦
- mariadb_test 创建的临时数据库
- /usr/local/mysql/support-files/systemd/mariadb.service #默认官方的服务脚本
- /usr/lib/systemd/system/mariadb.service 系统服务脚本(如果变更了目录请更改服务脚本内文件路径)
vi /mariadb_install.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/06/05
# increase indent:Tab
# decrease indent:Shift+Tab
# install source mariadb
<<!
download
https://archive.mariadb.org/
installing-mariadb-binary-tarballs
https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/
Document center
https://mariadb.com/kb/zh-cn/
!
install_mariadb (){
if ! compgen -u mysql &> /dev/null
then
if [ $? -eq 0 ];then
#download mariadb
mariadb_url=https://archive.mariadb.org/mariadb-10.11.3/bintar-linux-systemd-x86_64/
mariadb_gz=mariadb-10.11.3-linux-systemd-x86_64.tar.gz
#mariadb mysql user
mysql_user=mysql
mysql_root_password=Report@123
#mariadb directory
mysql_data=data
msyql_directory=mysql
mariadb_decompression_directory=mariadb-10.11.3-linux-systemd-x86_64
mysql_prefix=/usr/local/mysql
mysql_download=/tmp
echo "Create user and groups for mariadb Database service"
groupadd $mysql_user
useradd -r -s /sbin/nologin -g $mysql_user $mysql_user
echo "Firewall port development"
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
firewall-cmd --zone=public --add-port=3306/tcp --permanent && firewall-cmd --reload
echo "Dependent installation"
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y gcc gcc-c++ net-tools make cmake
yum -y install libncurses* zlib-devel libcurl-devel boost-devel ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio libaio-devel perl-Data-Dumper
echo "limits config"
cat >>/etc/security/limits.conf<<EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF
echo "system Maximum number of connections"
echo "fs.file-max=65535" >> /etc/sysctl.conf
echo "download mariadb"
wget -N -P $mysql_download $mariadb_url$mariadb_gz
echo "decompression mariadb"
tar -xf $mysql_download/$mariadb_gz -C $mysql_download
mv $mysql_download/$mariadb_decompression_directory $mysql_prefix
echo "The permission of the directory user is granted"
chown -R root $mysql_prefix
mkdir -p $mysql_prefix/$mysql_data
chown -R $mysql_user $mysql_prefix/$mysql_data
cat >>/etc/my.cnf<<EOF
[Client]
port=3306
default-character-set=utf8mb4
socket=$mysql_prefix/$mysql_data/mysql.sock
[mysqld]
basedir=$mysql_prefix
datadir=$mysql_prefix/$mysql_data
port=3306
socket=$mysql_prefix/$mysql_data/mysql.sock
pid-file=$mysql_prefix/$mysql_data/mysql.pid
max_connections=200
character_set_server=utf8mb4
collation-server=utf8mb4_unicode_ci
character-set-client-handshake=FALSE
default-storage-engine=INNODB
default-time_zone='+8:00'
log_bin_trust_function_creators = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket=$mysql_prefix/$mysql_data/mysql.sock
default-character-set=utf8mb4
EOF
echo "mariadb environment variable"
echo 'umask 022' >> ~/.bash_profile
echo 'PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile
source ~/.bash_profile
echo "initialize mariadb"
$mysql_prefix/scripts/mariadb-install-db --user=$mysql_user --basedir=$mysql_prefix --datadir=$mysql_prefix/$mysql_data
echo "system service mariadb"
cp -rf $mysql_prefix/support-files/systemd/mariadb.service /usr/lib/systemd/system/mariadb.service
systemctl daemon-reload
systemctl enable mariadb.service
systemctl start mariadb.service
echo "check mariadb version"
mysql -V | awk '{print $5}'
echo "Configuring the root Password"
$mysql_prefix/bin/mysql -e "alter user root@localhost identified by 'Report@123'; FLUSH PRIVILEGES;"
echo "Allow root to log in remotely"
$mysql_prefix/bin/mysql -uroot -p$mysql_root_password -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Report@123' WITH GRANT OPTION;"
echo "Create a library, create a user to give the user ownership of the library, create, delete, modify, super administrator rights"
$mysql_prefix/bin/mysql -uroot -p$mysql_root_password -e "CREATE DATABASE mariadb_test;"
$mysql_prefix/bin/mysql -uroot -p$mysql_root_password -e "CREATE USER mar@'%' IDENTIFIED BY 'Report@123';"
$mysql_prefix/bin/mysql -uroot -p$mysql_root_password -e "GRANT ALL PRIVILEGES ON *.* TO mar@'%' WITH GRANT OPTION;"
$mysql_prefix/bin/mysql -uroot -p$mysql_root_password -e "GRANT SUPER ON *.* TO mar@'%';"
echo "Deleting an installation package"
rm -rf $mysql_download/$mariadb_gz
echo -e "\033[32mThe mariadb Install Success...\033[0m"
else
echo -e "\033[31mThe mariadb Install Failed...\033[0m"
exit 1
fi
else
echo -e "\033[33mThe mariadb Install already...\033[0m"
fi
}
main (){
install_mariadb
}
main
执行一键安装 mariadb
sh /mariadb_install.sh