CentOS-6上安装二进制Mariadb
发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,前言:mariadb官方网站上提供了三种不同形式的程序包:源码包版、程序包管理器版、和二进制版,如下图所示。二进制版是由官方编译好的绿色版,相比源码包版安装更简单,比起程序包管理器版又多一点自由度,算
千家信息网最后更新 2025年02月02日CentOS-6上安装二进制Mariadb
前言:
mariadb官方网站上提供了三种不同形式的程序包:源码包版、程序包管理器版、和二进制版,如下图所示。二进制版是由官方编译好的绿色版,相比源码包版安装更简单,比起程序包管理器版又多一点自由度,算是二者的折中方案。另外要注意它依赖于glibc,需要注意glibc的版本。
安装:
步骤一:
首先确认glibc版本,可以看到CentOS-6上安装的是glibc-2.12版,所以需要下载
# rpm -q glibcglibc-2.12-1.166.el6.x86_64
步骤二:
关闭iptables和SElinux
步骤三:
# 创建系统用户mysql
# useradd -r mysql
# 解压至目录/usr/local/
# tar -xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/
# 创建软链接mysql
# cd /usr/local/# ln -sv mariadb-5.5.43-linux-x86_64/ mysql"mysql" -> "mariadb-5.5.43-linux-x86_64/"
# 修改目录属主和属组
# chown -R root:mysql .
# 创建数据库目录。如果不单独创建并指定则默认使用当前目录下的data目录作为数据库目录
# mkdir -pv /data/mysqlmkdir: created directory `/data'mkdir: created directory `/data/mysql'
# 修改数据库目录的属主和属组为mysql
# chown -R mysql:mysql /data/mysql/
# 安装数据库
# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
配置
# 将bin目录路径导入PATH环境变量
# vim /etc/profile.d/mysql.shexport PATH=/usr/local/mysql/bin:$PATH
# 立即生效
# exec bash
# 创建头文件符号链接
# cd /usr/local/include/# ln -s ../mysql/include/mysql/ mysql
# 将man路径导入系统man手册
# vim /etc/man.configMANPATH /usr/local/mysql/man
# 拷贝服务脚本至/etc/rc.d/init.d目录
# cd /usr/local/mysql# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# 复制模板配置文件至/etc/目录
# cp support-files/my-large.cnf /etc/my.cnf
# 修改配置文件
# vim /etc/my.cnf
字符集:
mysqld为服务端,mysql为本地cli命令行工具,client为客户端连接工具包括远程连接工具等。均需要将字符集统一设置为utf-8,特殊场景根据实际情况修改为其他字符集。
[client]default-charater-set=utf8[mysql]default-charater-set=utf8[mysqld]character-set-server=utf8
字符排序:
[mysqld]collation-server=utf8_general_ci
数据库目录
[mysqld]datadir=/data/mysql
存储引擎
[mysqld]# 默认使用innodb存储引擎default-storage-engine=InnoDB# 每张表都使用独立表空间innodb-file-per-table=TRUE
关闭域名反解
skip-name-resolve=TRUE
配置完成后应该是这个样子
[client]port = 3306socket = /tmp/mysql.sockdefault-character-set=utf8[mysqld]datadir=/data/mysqlport = 3306socket = /tmp/mysql.sockskip-external-lockingkey_buffer_size = 256Mmax_allowed_packet = 1Mtable_open_cache = 256sort_buffer_size = 1Mread_buffer_size = 1Mread_rnd_buffer_size = 4Mmyisam_sort_buffer_size = 64Mthread_cache_size = 8query_cache_size= 16Mthread_concurrency = 8character-set-server=utf8collation-server=utf8_general_cidefault-storage-engine=InnoDBinnodb-file-per-table=TRUEskip-name-resolve=TRUElog-bin=mysql-binskip-name-resolve=TRUElog-bin=mysql-binbinlog_format=mixedserver-id = 1[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehashdefault-character-set=utf8[myisamchk]key_buffer_size = 128Msort_buffer_size = 128Mread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout
启动服务
/etc/init.d/mysqld start
开机自启动
chkconfig --add mysqldchkconfig mysqld on
安全设置
# mysql_secure_installation /usr/local/mysql/bin/mysql_secure_installation: line 379: find_mysql_client: command not foundNOTE: 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 currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.# 初始root密码为空,直接回车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 MariaDBroot user without the proper authorisation.#设置root密码Set root password? [Y/n] n ... skipping.By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.# 删除匿名用户Remove anonymous users? [Y/n] n ... skipping.Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.# 不允许root远程登陆Disallow root login remotely? [Y/n] n ... skipping.By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.# 删除test数据库以及访问它的权限设置Remove test database and access to it? [Y/n] n ... skipping.Reloading the privilege tables will ensure that all changes made so farwill 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 MariaDBinstallation should now be secure.Thanks for using MariaDB!
目录
数据
数据库
字符
配置
字符集
工具
文件
步骤
程序
服务
二进制
官方
密码
引擎
权限
源码
版本
用户
系统
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
天气预报的定位服务器已关啥意思
庆余年安卓服务器
乌克兰游戏用什么服务器
软件开发石家庄工资标准
财务管理系统服务器名
虹口区智能化软件开发信息中心
北京惠下单网络技术有限公司
路由器软件开发实验
软件开发额广告策划案
自动化设备定制服务器
福州软件开发大学
郧西互联网软件开发品质保障
服务器开启但是不开门
属于无线网络技术的是什么
无线网络安全设置配置命令
我的世界服务器关闭作弊
云原生 无服务器计算
小学网络技术掌握
孝感计算机软件开发费用
mc服务器怎么关发包限制
网络安全信息的5个基本要素
数据库的索引机制
配置boa服务器
机关网络安全规划
怎么架设家用的服务器
衡板 软件开发
系统无法访问数据库是因为死锁吗
网络安全专业在山东的好大学
陕西数据库安全审计
监控服务器时间是否准确