Centos7源码编译安装mariadb10.4.13

2023-05-16

一 安装前的准备

1. 安装阿里base及epel源
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
2.安装mariadb的依赖包
[root@localhost ~]# yum install -y boost gcc gcc-c++ ncurses-devel libaio bison git cmake openssl openssl-devel  
3.下载并解压mariadb10.4.13
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget -c [root@localhost src]# wget -c https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.4.13/source/mariadb-10.4.13.tar.gz
[root@localhost src]# tar -zxvf mariadb-10.4.13.tar.gz
[root@localhost src]# cd mariadb-10.4.13/

二 编译安装mariadb

//预编译
[root@localhost mariadb-10.4.13]# cmake -j4 . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \
-DMYSQL_DATADIR=/data/mariadb/ \
-DSYSCONFDIR=/usr/local/mariadb \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITHOUT_TOKUDB=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
//编译
[root@localhost mariadb-10.4.13]# make -j4
//安装
[root@localhost mariadb-10.4.13]# make install -j4

三 配置启动文件及权限

[root@localhost mariadb-10.4.13]# cd /usr/local/mariadb/
[root@localhost mariadb]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mariadb]# chmod +x /etc/init.d/mysqld
[root@localhost mariadb]# mkdir -p /data/mariadb/
[root@localhost mariadb]# chown -R mysql. /data/mariadb
[root@localhost mariadb]# chown -R mysql:mysql /usr/local/mariadb/

四 配置数据库文件

[root@localhost mariadb]# vim /usr/local/mariadb/my.cnf
[mysqld]
basedir=/usr/local/mariadb/
datadir=/data/mariadb/
port=3306
pid-file=/data/mariadb/mysql.pid
socket=/tmp/mysql.sock

[mysqld_safe]
log-error=/data/mariadb/mysql.log

[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8

五 数据库初始化

[root@localhost mariadb]# /usr/local/mariadb/scripts/mariadb-install-db --datadir=/data/mariadb/ 
Installing MariaDB/MySQL system tables in '/data/mariadb/' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is root@localhost, it has no password either, but
you need to be the system 'root' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/data/mariadb/'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

六 更改目录权限

//安装目录权限改为root
[root@localhost mariadb]# chown -R root. /usr/local/mariadb/
//数据目录权限改为mysql
[root@localhost mariadb]# chown -R mysql:mysql /data/mariadb/

七 启动并登录mariadb

//启动
[root@localhost mariadb]# /etc/init.d/mysqld start

我在这里遇到一个坑:启动失败,查看日志里有这句
Starting MySQL…/etc/init.d/mysql: line 264 kill : (30695)-No such process

解决方法:
编辑mysqld

[root@localhost mariadb]# vi /etc/rc.d/init.d/mysqld
//打开mysqld后使用命令(/$bindir/mysqld_safe)向下搜索找到这行:
$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
//修改为(加上参数--user=root):
$bindir/mysqld_safe --user=root --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &

然后再试:

[root@localhost mariadb]# service mysqld start

启动成功。

//登录
[root@localhost mariadb]# /usr/local/mariadb/bin/mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.13-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

八 数据安全配置

[root@localhost mariadb]# /usr/local/mariadb/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
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the 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] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will 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 MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@localhost mariadb]# 

九 配置环境变量

//配置变量脚本
[root@localhost mariadb]# echo "export PATH=/usr/local/mariadb/bin:$PATH" >/etc/profile.d/mariadb.sh
//执行脚本
[root@localhost mariadb]# . /etc/profile.d/mariadb.sh 
//就可以直接以mysql登录了
[root@localhost mariadb]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.4.13-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Centos7源码编译安装mariadb10.4.13 的相关文章

随机推荐

  • Ubuntu16.04中VSCode提取扩展时出错:XHR failed

    1 Ubuntu16 04下载VSCode后无法下载扩展程序 xff0c 出现error while fetching extensions xhr failed XHR failed 2 VSCode内F1 gt Developer To
  • lottie android 卡顿,lottie动画设计_免异常总结

    导语 lottie的出现给设计师和开发带来了极大的便利 设计师设计的动画可以百分百还原 但是在使用过程中可能会遇到不少显示异常或者性能问题 xff0c 因此结合lottie官方文档以及我在实践中遇到的问题做了如下总结 Introductio
  • typescript egg mysql_egg-sequelize+typescript一对一关联查询错误

    这里我创建了两张表 xff0c 一张是文章表 xff0c 一张是文章类型表 文章表model app model Article ts import Application from 39 egg 39 export default fun
  • 封装虚拟机系统到服务器,封装自己的虚拟机系统

    封装自己的虚拟机系统 内容精选 换一换 Hypervisor能实现同一物理机上不同虚拟机之间的资源隔离 xff0c 避免虚拟机之间的数据窃取或恶意攻击 xff0c 保证虚拟机的资源使用不受周边虚拟机的影响 用户使用虚拟机时 xff0c 仅能
  • 送给前线码农的话 - 大牛们的经典语录

    点击上方 程序人生 xff0c 选择 置顶公众号 第一时间关注程序猿 xff08 媛 xff09 身边的故事 近半年来 xff0c 本人几乎天天逛各大论坛网站 xff0c 浏览大牛们的博客 xff0c get了不少经典的好词好段 xff0c
  • win server2012远程桌面允许多用户同时登录配置

    注意 xff1a 安装过程中如没有出现某些画面 xff0c 直接默认下一步 目录 xff1a 一 安装远程远程桌面服务 二 激活远程桌面授权管理器与安装许可证 三 修改本地组策略 xff0c 做授权 一 安装远程远程桌面服务 注意 xff1
  • [Matlab学习笔记]Matlab中删除矩阵指定行(指定列)

    在用matlab编程进行GNSS粗差提取时 xff0c 想实现对某矩阵删除指定行 xff08 指定列 xff09 的命令 xff0c 下文中描述的均为行 通过百度 xff0c 先明白对于一行数据而言 xff0c 删除指定位置的元素的原理 主
  • 面试问题:SpringMVC的执行流程

    Spring MVC 执行流程 Spring MVC 执行流程如下图所示 xff1a SpringMVC 的执行流程如下 xff1a 用户点击某个请求路径 xff0c 发起一个 HTTP request 请求 xff0c 该请求会被提交到
  • Royal TSX连接服务器总是自动断开

    2022 05 10 发布 xff0c 亲测有效
  • mac终端启动jupyter:command not found

    mac终端启动jupyter xff1a command not found 原因是未在系统的环境变量中添加 jupyter的路径 anaconda bin 添加上即可 添加方法有多种 xff0c 可以在 etc profile etc p
  • VBoxManage 命令操作,详细的网络设置命令

    VBoxManage v version 显示virtualbox的版本号 VBoxManage nologo 隐藏logo VBoxManage convertSettings 允许自动转换设置文件 VBoxManage convertS
  • 屏蔽百度热榜/关闭百度热榜

    关键词 xff1a 屏蔽百度热榜 关闭百度热榜 抱歉 xff0c 热榜真的烦 xff0c 本来自制力就不好 如果没有拦截元素 xff0c 刷新一下就好 baidu com FYB RD
  • uniapp中使用iconfont

    忘记是哪位博主了 xff0c 上回看到了博文 xff0c 学会了就没管了 这次又用到了 xff0c 还是记录一下好 开发环境只试了app xff0c 其它环境未知 xff01 xff01 xff01 正文 xff1a 1 iconfont新
  • MyBatis报错

    MyBatis报错 Error starting ApplicationContext To display the conditions report re run your application with debug enabled
  • 使用WinSCP连接阿里云轻量服务器

    使用WinSCP连接阿里云轻量服务器 准备 xff1a 下载PuTTYgen xff0c WinSCP 使用第二种方式连接 设置完成以后 xff0c 会下载一个pem格式的密钥 使用PuTTYgen转换成ppk格式的文件 保存文件即可 接下
  • 程序员找工作的个人经验教训以及注意事项

    点击上方 程序人生 xff0c 选择 置顶公众号 第一时间关注程序猿 xff08 媛 xff09 身边的故事 忽然间想到如果要找工作的话 xff0c 需要注意一些什么问题 没毕业的 xff0c 刚刚毕业的 xff0c 刚刚工作的都可以借鉴一
  • MyBatis Plus 的乐观锁的使用

    MyBatis Plus 的乐观锁的使用 1 首先要向SpringBoot容器中注册 写在 64 Configuration的类下 span class token comment 乐观锁 span span class token ann
  • win7卡在windows update 35%的解决方法

    系统更新到一半被打断 xff0c 开机重启一直卡在Windows Update 35 转圈圈数小时 xff0c 无法进入系统 强制按关机键 xff0c F8进入安全模式依然同样现象 网上查阅得知 xff0c 有人提到用DISM撤销上次的系统
  • 启动分区不存在,使用分区工具修正

    这几天想着装双系统 xff0c Win10 43 kali 结果kali装好 xff0c Win10打不开了 就想着用老毛桃修复引导看一下 结果修复工具就提示 xff0c 启动分区不存在 xff0c 使用分区工具修正 xff08 图没拍照记
  • Centos7源码编译安装mariadb10.4.13

    一 安装前的准备 1 安装阿里base及epel源 span class token punctuation span root 64 localhost span class token operator span span class