CentOS-6上安装二进制Mariadb
发表于:2025-11-10 作者:千家信息网编辑
千家信息网最后更新 2025年11月10日,前言:mariadb官方网站上提供了三种不同形式的程序包:源码包版、程序包管理器版、和二进制版,如下图所示。二进制版是由官方编译好的绿色版,相比源码包版安装更简单,比起程序包管理器版又多一点自由度,算
千家信息网最后更新 2025年11月10日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安全错误
数据库的锁怎样保障安全
软考往年试题数据库
软件开发方法与步骤
浙江哪里有游戏软件开发的
法律规定的信息网络安全的概念
金凤区政务软件开发费用
access数据库远程共享
oracle打开已建的数据库
南通云服务器服务商
自己搞个软件开发工作室
金融软件开发职位P11
长海软件开发设计
三级网络技术5条报文
软件开发属于哪类学校
成都华数网络技术
steam魂2无法登录服务器
ibm服务器管理口进不去
sql中如何附加数据库文件
数据库多对多的联系要建表吗
深圳学网络技术培训学校
怎么禁用orcal数据库
动画制作与vr软件开发
用自己的网络安全吗
中国网络安全工程师认证
增城网络安全服务价格
软件开发排行
关系型数据库的优化算法
中学网络安全情景剧剧本
网络安全法关于检测的规定
小平网络技术分享2017
编程实现数据库管理系统