热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

centos7.3二进制安装mariadb

官网二进制mariadb很多配置使写死的。所以配置文件的位置请留意不要出错哦。如usrloaclmysql等。1.确认没有maraiadb*包rpm-qamariadb*查看无包

官网二进制mariadb很多配置使写死的。所以配置文件的位置请留意不要出错哦。如/usr/loacl/mysql等。


1.确认没有maraiadb*包

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

mariadb软件包官网下载即可。


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.准备配置文件

mkdir /etc/mysql

cp /usr/local/mysqlsupport-files/my-huge.cnf /etc/mysql/my.cnf

vim /etc/mysql/my.cnf

下面意为[mysqld]行下加入如下三行。

[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@centos7 mysql]# ./scripts/mysql_install_db --datadir=/app/mysqldb --user=mysqlInstalling MariaDB/MySQL system tables in '/app/mysqldb' ...
2017-10-11 20:08:53 140592457275200 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2017-10-11 20:08:55 140592457275200 [ERROR] ./bin/mysqld: unknown variable 'datedir=/app/mysqldb'
2017-10-11 20:08:55 140592457275200 [ERROR] Aborting


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

cp support-files/mysql.server /etc/init.d/mysqld

chkconfig --list mysqld

chkconfig --add mysqld

service mysqld start

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

[root@centos7 mysql]# service mysqld startStarting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.                                                           [FAILED][root@centos7 mysql]# systemctl status mysqld.service -l● mysqld.service - LSB: start and stop MySQL   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)   Active: failed (Result: exit-code) since Wed 2017-10-11 20:20:27 CST; 3min 32s ago     Docs: man:systemd-sysv-generator(8)  Process: 10519 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)Oct 11 20:20:26 centos7.magedu.com systemd[1]: Starting LSB: start and stop MySQL...Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: Starting MySQL.171011 20:20:26 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: 171011 20:20:26 mysqld_safe Starting mysqld daemon with databases from /app/mysqldbOct 11 20:20:26 centos7.magedu.com mysqld[10519]: [133B blob data]Oct 11 20:20:27 centos7.magedu.com mysqld[10519]: ERROR!Oct 11 20:20:27 centos7.magedu.com systemd[1]: mysqld.service: control process exited, code=exited status=1Oct 11 20:20:27 centos7.magedu.com systemd[1]: Failed to start LSB: start and stop MySQL.Oct 11 20:20:27 centos7.magedu.com systemd[1]: Unit mysqld.service entered failed state.Oct 11 20:20:27 centos7.magedu.com systemd[1]: mysqld.service failed.

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

touch /var/log/mariadb/mariadb.log

chown mysql /var/log/mariadb/mariadb.log

chown mysql /var/log/mariadb

service mysqld start 


7.安全初始化环境配置

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

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

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

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

A:

[root@centos7 bin]# cd /usr/local/mysql/bin[root@centos7 bin]# ./mysql_secure_installation NOTE: 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.Enter current password for root (enter for none):

B:查看当前登录用户

[root@centos7 ~]# mysqlWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 10Server version: 10.2.8-MariaDB-log MariaDB ServerCopyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> select user();+----------------+| user()         |+----------------+| root@localhost |+----------------+1 row in set (0.00 sec)

A:

[root@centos7 bin]# ./mysql_secure_installation NOTE: 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.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.Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!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]

B:

[root@centos7 ~]# mysqlERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

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



本文出自 “RightNow” 博客,请务必保留此出处http://amelie.blog.51cto.com/12850951/1971534


推荐阅读
  • 安装mysqlclient失败解决办法
    本文介绍了在MAC系统中,使用django使用mysql数据库报错的解决办法。通过源码安装mysqlclient或将mysql_config添加到系统环境变量中,可以解决安装mysqlclient失败的问题。同时,还介绍了查看mysql安装路径和使配置文件生效的方法。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • MyBatis多表查询与动态SQL使用
    本文介绍了MyBatis多表查询与动态SQL的使用方法,包括一对一查询和一对多查询。同时还介绍了动态SQL的使用,包括if标签、trim标签、where标签、set标签和foreach标签的用法。文章还提供了相关的配置信息和示例代码。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 如何用UE4制作2D游戏文档——计算篇
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了如何用UE4制作2D游戏文档——计算篇相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • eclipse学习(第三章:ssh中的Hibernate)——11.Hibernate的缓存(2级缓存,get和load)
    本文介绍了eclipse学习中的第三章内容,主要讲解了ssh中的Hibernate的缓存,包括2级缓存和get方法、load方法的区别。文章还涉及了项目实践和相关知识点的讲解。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOMEbinjava–option来启 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • 本文介绍了在MacOS系统上安装MySQL的步骤,并详细说明了如何设置MySQL服务的开机启动和如何修改MySQL的密码。通过下载MySQL的macos版本并按照提示一步一步安装,在系统偏好设置中可以找到MySQL的图标进行设置。同时,还介绍了通过终端命令来修改MySQL的密码的具体操作步骤。 ... [详细]
  • Python项目实战10.2:MySQL读写分离性能优化
    本文介绍了在Python项目实战中进行MySQL读写分离的性能优化,包括主从同步的配置和Django实现,以及在两台centos 7系统上安装和配置MySQL的步骤。同时还介绍了创建从数据库的用户和权限的方法。摘要长度为176字。 ... [详细]
  • 使用nodejs爬取b站番剧数据,计算最佳追番推荐
    本文介绍了如何使用nodejs爬取b站番剧数据,并通过计算得出最佳追番推荐。通过调用相关接口获取番剧数据和评分数据,以及使用相应的算法进行计算。该方法可以帮助用户找到适合自己的番剧进行观看。 ... [详细]
  • C++字符字符串处理及字符集编码方案
    本文介绍了C++中字符字符串处理的问题,并详细解释了字符集编码方案,包括UNICODE、Windows apps采用的UTF-16编码、ASCII、SBCS和DBCS编码方案。同时说明了ANSI C标准和Windows中的字符/字符串数据类型实现。文章还提到了在编译时需要定义UNICODE宏以支持unicode编码,否则将使用windows code page编译。最后,给出了相关的头文件和数据类型定义。 ... [详细]
  • ubuntu用sqoop将数据从hive导入mysql时,命令: ... [详细]
author-avatar
欣欣大妮
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有