centos7.3二进制安装mariadb

前端之家收集整理的这篇文章主要介绍了centos7.3二进制安装mariadb前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


centos7.3二进制安装mariadb.10.2.8


1.确认没有maraiadb*

rpm -qa mariadb*查看无包即可,若有,用yum remove卸载

2.useradd -d /app/MysqLdb -r -m -s /sbin/nologin MysqL

getent passwd MysqL

建议放在逻辑卷上,数据库会不断变大,不能扩展的分区后期处理起来就麻烦多了。

3. tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local

cd /usr/local

ln -sv mariadb-10.2.8-linux-x86_64 MysqL v显示过程


4.准备配置文件

cd /usr/local/MysqL

ls support-files/

mkdir /etc/MysqL

cp /usr/local/MysqLsupport-files/my-huge.cnf /etc/MysqL/my.cnf

vim /etc/MysqL/my.cnf

[MysqLd]

datadir = /app/MysqLdb 必须加

innodb_file_per_table = on 每表为一独立文件

skip_name_resolve = on 性能优化,禁止主机名解析

5../scripts/MysqL_install_db --user=MysqL --datadir=/app/MysqLdb 运行脚本,创建系统数据库

ls /app/MysqLdb 有东西了

(可能有报错,根据报错提醒,逐一排错)

因为是二进制编译,有些配置文件的位置是设定好的,这点需注意。

[root@centos7MysqL]#./scripts/MysqL_install_db--datadir=/app/MysqLdb--user=MysqL
InstallingMariaDB/MysqLsystemtablesin'/app/MysqLdb'...
2017-10-1120:08:53140592457275200[Warning]'THREAD_CONCURRENCY'isdeprecatedandwillberemovedinafuturerelease.
2017-10-1120:08:55140592457275200[ERROR]./bin/MysqLd:unknownvariable'datedir=/app/MysqLdb'
2017-10-1120:08:55140592457275200[ERROR]Aborting


6.准备服务脚本,并启动服务

cp support-files/MysqL.server /etc/init.d/MysqLd

chkconfig --list MysqLd

chkconfig --add MysqLd

service MysqLd start

下面是服务不能启动的情况

[root@centos7MysqL]#serviceMysqLdstart
StartingMysqLd(viasystemctl):JobforMysqLd.serviceFailedbecausethecontrolprocessexitedwitherrorcode.See"systemctlstatusMysqLd.service"and"journalctl-xe"fordetails.
[Failed]
[root@centos7MysqL]#systemctlstatusMysqLd.service-l
●MysqLd.service-LSB:startandstopMysqL
Loaded:loaded(/etc/rc.d/init.d/MysqLd;bad;vendorpreset:disabled)
Active:Failed(Result:exit-code)sinceWed2017-10-1120:20:27CST;3min32sago
Docs:man:systemd-sysv-generator(8)
Process:10519ExecStart=/etc/rc.d/init.d/MysqLdstart(code=exited,status=1/FAILURE)

Oct1120:20:26centos7.magedu.comsystemd[1]:StartingLSB:startandstopMysqL...
Oct1120:20:26centos7.magedu.comMysqLd[10519]:StartingMysqL.17101120:20:26MysqLd_safeLoggingto'/var/log/mariadb/mariadb.log'.
Oct1120:20:26centos7.magedu.comMysqLd[10519]:17101120:20:26MysqLd_safeStartingMysqLddaemonwithdatabasesfrom/app/MysqLdb
Oct1120:20:26centos7.magedu.comMysqLd[10519]:[133Bblobdata]
Oct1120:20:27centos7.magedu.comMysqLd[10519]:ERROR!
Oct1120:20:27centos7.magedu.comsystemd[1]:MysqLd.service:controlprocessexited,code=exitedstatus=1
Oct1120:20:27centos7.magedu.comsystemd[1]:FailedtostartLSB:startandstopMysqL.
Oct1120:20:27centos7.magedu.comsystemd[1]:UnitMysqLd.serviceenteredFailedstate.
Oct1120:20:27centos7.magedu.comsystemd[1]:MysqLd.serviceFailed.

可以看到缺少了日志文件,日志文件对于MysqL数据库还是很重要的。有时出现任务进行一半意外中断的情况,日志可以快速排错。接下来我们创建日志文件。注意权限。权限不对会导致服务无法启动。

touch /var/log/mariadb/mariadb.log

chown MysqL /var/log/mariadb/mariadb.log

chown MysqL /var/log/mariadb


7.安全初始化环境配置

主要包括PATH环境变量及安全环境。

[root@centos7 MysqL]# vim /etc/profile.d/MysqL.sh

PATH=/usr/local/MysqL/bin/:$PATH

可以同时开一个终端测试.

A:

[root@centos7bin]#cd/usr/local/MysqL/bin
[root@centos7bin]#./MysqL_secure_installation
NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB
SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!
InordertologintoMariaDBtosecureit,we'llneedthecurrent
passwordfortherootuser.Ifyou'vejustinstalledMariaDB,and
youhaven'tsettherootpasswordyet,thepasswordwillbeblank,soyoushouldjustpressenterhere.
Entercurrentpasswordforroot(enterfornone):

B:查看当前登录用户

[root@centos7~]#MysqL
WelcometotheMariaDBmonitor.Commandsendwith;or\g.
YourMariaDBconnectionidis10
Serverversion:10.2.8-MariaDB-logMariaDBServer
Copyright(c)2000,2017,Oracle,MariaDBCorporationAbandothers.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
MariaDB[(none)]>selectuser();
+----------------+
|user()|
+----------------+
|root@localhost|
+----------------+
1rowinset(0.00sec)

A:

[root@centos7bin]#./MysqL_secure_installation

NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB
SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!

InordertologintoMariaDBtosecureit,soyoushouldjustpressenterhere.

Entercurrentpasswordforroot(enterfornone):
OK,successfullyusedpassword,movingon...

SettingtherootpasswordensuresthatnobodycanlogintotheMariaDB
rootuserwithouttheproperauthorisation.

Setrootpassword?[Y/n]y
Newpassword:
Re-enternewpassword:
Passwordupdatedsuccessfully!
Reloadingprivilegetables..
...Success!
Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyone
tologintoMariaDBwithouthavingtohaveauseraccountcreatedfor
them.Thisisintendedonlyfortesting,andtomaketheinstallation
goabitsmoother.Youshouldremovethembeforemovingintoa
productionenvironment.
Removeanonymoususers?[Y/n]

B:

[root@centos7~]#MysqL
ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:NO)

设置完成后再以root身份登录就要执行MysqL -uroot -p命令了。

原文链接:https://www.f2er.com/centos/375627.html

猜你在找的CentOS相关文章