CentOS-6上安装二进制Mariadb
前言:
mariadb官方网站上提供了三种不同形式的程序包:源码包版、程序包管理器版、和二进制版,如下图所示。二进制版是由官方编译好的绿色版,相比源码包版安装更简单,比起程序包管理器版又多一点自由度,算是二者的折中方案。另外要注意它依赖于glibc,需要注意glibc的版本。
安装:
步骤一:
首先确认glibc版本,可以看到CentOS-6上安装的是glibc-2.12版,所以需要下载
#rpm-qglibcglibc-2.12-1.166.el6.x86_64
步骤二:
关闭iptables和SElinux
步骤三:
# 创建系统用户mysql
#useradd-rmysql
# 解压至目录/usr/local/
#tar-xfmariadb-5.5.43-linux-x86_64.tar.gz-C/usr/local/
# 创建软链接mysql
#cd/usr/local/#ln-svmariadb-5.5.43-linux-x86_64/mysql"mysql"->"mariadb-5.5.43-linux-x86_64/"
#修改目录属主和属组
#chown-Rroot:mysql.
# 创建数据库目录。如果不单独创建并指定则默认使用当前目录下的data目录作为数据库目录
#mkdir-pv/data/mysqlmkdir:createddirectory`/data'mkdir:createddirectory`/data/mysql'
# 修改数据库目录的属主和属组为mysql
#chown-Rmysql:mysql/data/mysql/
# 安装数据库
#scripts/mysql_install_db--user=mysql--datadir=/data/mysql
配置
# 将bin目录路径导入PATH环境变量
#vim/etc/profile.d/mysql.shexportPATH=/usr/local/mysql/bin:$PATH
# 立即生效
#execbash
# 创建头文件符号链接
#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#cpsupport-files/mysql.server/etc/rc.d/init.d/mysqld
# 复制模板配置文件至/etc/目录
#cpsupport-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/mysqldstart
开机自启动
chkconfig--addmysqldchkconfigmysqldon
安全设置
#mysql_secure_installation/usr/local/mysql/bin/mysql_secure_installation:line379:find_mysql_client:commandnotfoundNOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDBSERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!InordertologintoMariaDBtosecureit,we'llneedthecurrentpasswordfortherootuser.Ifyou'vejustinstalledMariaDB,andyouhaven'tsettherootpasswordyet,thepasswordwillbeblank,soyoushouldjustpressenterhere.#初始root密码为空,直接回车Entercurrentpasswordforroot(enterfornone):OK,successfullyusedpassword,movingon...SettingtherootpasswordensuresthatnobodycanlogintotheMariaDBrootuserwithouttheproperauthorisation.#设置root密码Setrootpassword?[Y/n]n...skipping.Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyonetologintoMariaDBwithouthavingtohaveauseraccountcreatedforthem.Thisisintendedonlyfortesting,andtomaketheinstallationgoabitsmoother.Youshouldremovethembeforemovingintoaproductionenvironment.#删除匿名用户Removeanonymoususers?[Y/n]n...skipping.Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.Thisensuresthatsomeonecannotguessattherootpasswordfromthenetwork.#不允许root远程登陆Disallowrootloginremotely?[Y/n]n...skipping.Bydefault,MariaDBcomeswithadatabasenamed'test'thatanyonecanaccess.Thisisalsointendedonlyfortesting,andshouldberemovedbeforemovingintoaproductionenvironment.#删除test数据库以及访问它的权限设置Removetestdatabaseandaccesstoit?[Y/n]n...skipping.Reloadingtheprivilegetableswillensurethatallchangesmadesofarwilltakeeffectimmediately.#重载权限列表Reloadprivilegetablesnow?[Y/n]y...Success!Cleaningup...Alldone!Ifyou'vecompletedalloftheabovesteps,yourMariaDBinstallationshouldnowbesecure.ThanksforusingMariaDB!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。