centos7.3二进制安装mariadb

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

官网二进制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 有东西了

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

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

1
2
3
4
5
[root@centos7 mysql] # ./scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
Installing 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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@centos7 mysql] # service mysqld start
Starting 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/mysqldb
Oct 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=1
Oct 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:

1
2
3
4
5
6
7
8
9
[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 current
password  for  the root user.  If you've just installed MariaDB, and
you 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:查看当前登录用户

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@centos7 ~] # mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection  id  is 10
Server version: 10.2.8-MariaDB-log MariaDB Server
Copyright (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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[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 current
password  for  the root user.  If you've just installed MariaDB, and
you 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 MariaDB
root user without the proper authorisation.
 
Set root password? [Y /n ] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
  ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created  for
them.  This is intended only  for  testing, and to  make  the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous  users ? [Y /n ]

B:

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

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

















本文转自阿拉杜美美51CTO博客,原文链接: http://blog.51cto.com/amelie/1971534,如需转载请自行联系原作者




相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25
|
15天前
|
监控 Linux PHP
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
65 20
|
1月前
|
存储 分布式计算 Hadoop
Centos7.9安装kerberos
Centos7.9安装kerberos
86 25
|
1月前
|
存储 Shell 网络安全
Centos7.9安装openldap
Centos7.9安装openldap
58 16
|
1月前
|
数据可视化 Linux 应用服务中间件
Centos7.9安装phpldapadmin
Centos7.9安装phpldapadmin
62 15
|
1月前
|
网络协议 Java 应用服务中间件
centos7环境下tomcat8的安装与配置
本文介绍了在Linux环境下安装和配置Tomcat 8的详细步骤。首先,通过无网络条件下的文件交互软件(如Xftp 6或MobaXterm)下载并解压Tomcat安装包至指定路径,启动Tomcat服务并测试访问。接着,修改Tomcat端口号以避免冲突,并部署Java Web应用项目至Tomcat服务器。最后,调整Linux防火墙规则,确保外部可以正常访问部署的应用。关键步骤包括关闭或配置防火墙、添加必要的端口规则,确保Tomcat服务稳定运行。
|
3月前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第16天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括配置系统源、安装 SQL Server 2019 软件包以及数据库初始化,确保 SQL Server 正常运行。
168 4
|
3月前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第8天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括系统准备、配置安装源、安装 SQL Server 软件包、运行安装程序、初始化数据库以及配置远程连接。通过这些步骤,您可以顺利地在 CentOS 系统上部署和使用 SQL Server 2019。
178 1
|
3月前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第7天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括系统要求检查与准备、配置安装源、安装 SQL Server 2019、配置 SQL Server 以及数据库初始化(可选)。通过这些步骤,你可以成功安装并初步配置 SQL Server 2019,进行简单的数据库操作。
108 1
|
3月前
|
存储 安全 Linux
VMware安装CentOS7
【11月更文挑战第11天】本文详细介绍了在 VMware 中安装 CentOS 7 的步骤,包括准备工作、创建虚拟机、配置虚拟机硬件和安装 CentOS 7。具体步骤涵盖下载 CentOS 7 镜像文件、安装 VMware 软件、创建和配置虚拟机硬件、启动虚拟机并进行安装设置,最终完成 CentOS 7 的安装。在安装过程中,需注意合理设置磁盘分区、软件选择和网络配置,以确保系统的性能和功能满足需求。
429 0

热门文章

最新文章