hugo-teek is loading...

MariaDB部署-源码编译方式

最后更新于:

实战:源码编译安装mariadb(10.2.19)-2024.4.18(测试成功)

image-20240418075612292

目录

[toc]

实验环境

1centos7.6 1810
2mariadb(10.2.19)

实验软件

链接:https://pan.baidu.com/s/1qN4WGr8yvPn2VYrkB5rW9Q?pwd=o9av 提取码:o9av 2024.4.18-实战:源码编译安装mariadb(10.2.19)-2024.4.18(测试成功)

image-20240418210511528

安装相关依赖包

1yum -y install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel  gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel

做准备用户和数据目录

1useradd -r -s /sbin/nologin -d /data/mysql mysql

准备数据库目录

1mkdir   -p /data/mysql
2chown mysql.mysql /data/mysql

源码编译安装

  • 下载并解压缩源码包
1tar xvf mariadb-10.2.19.tar.gz
  • 源码编译安装mariadb
 1cd mariadb-10.2.19/
 2cmake . \
 3-DCMAKE_INSTALL_PREFIX=/app/mysql \
 4-DMYSQL_DATADIR=/data/mysql/ \
 5-DSYSCONFDIR=/etc/ \
 6-DMYSQL_USER=mysql \
 7-DWITH_INNOBASE_STORAGE_ENGINE=1 \
 8-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
 9-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
10-DWITH_PARTITION_STORAGE_ENGINE=1 \
11-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \
12-DWITH_DEBUG=0 \
13-DWITH_READLINE=1 \
14-DWITH_SSL=system \
15-DWITH_ZLIB=system \
16-DWITH_LIBWRAP=0 \
17-DENABLED_LOCAL_INFILE=1 \
18-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
19-DDEFAULT_CHARSET=utf8 \
20-DDEFAULT_COLLATION=utf8_general_ci
21
22#make && make install
23make -j 8 && make install; date

提示:如果出错,执行rm -f CMakeCache.txt

准备环境变量

1echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
2.     /etc/profile.d/mysql.sh

生成数据库文件

1cd /app/mysql/
2/app/mysql/scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql

准备配置文件

1cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf

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

1cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
2#chkconfig --list
3chkconfig --add mysqld
4chkconfig --list
5#service mysqld start
6systemctl start mysql

安全初始化

 1mysql_secure_installation
 2
 3#/usr/local/mysql/bin/mysql_secure_installation
 4
 5Enter current password for root (enter for none): #默认没密码,这里直接回车
 6
 7
 8You already have your root account protected, so you can safely answer 'n'.
 9Switch to unix_socket authentication [Y/n] #输入n(远程可以登录)
10
11#mysql.sock 使用unix socket登录(只能在本地登录,不能远程登录);
12/var/lib/mysql/mysql.sock文件
13
14Change the root password? [Y/n] #输入y
15New password: #输入密码:xyy520
16Re-enter new password: 
17
18Remove anonymous users? [Y/n] #输入y
19
20Disallow root login remotely? [Y/n] #输入y,禁用root远程登录
21
22Remove test database and access to it? [Y/n] #输入y
23
24Reload privilege tables now? [Y/n] #输入y(是否加载权限)

测试

 1[root@vm-template mysql]#mysql -uroot -pxyy520
 2Welcome to the MariaDB monitor.  Commands end with ; or \g.
 3Your MariaDB connection id is 20
 4Server version: 10.2.19-MariaDB-log Source distribution
 5
 6Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 7
 8Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 9
10MariaDB [(none)]> show databases;
11+--------------------+
12| Database           |
13+--------------------+
14| information_schema |
15| mysql              |
16| performance_schema |
17+--------------------+
183 rows in set (0.00 sec)
19
20MariaDB [(none)]> use mysql;
21Database changed
22MariaDB [mysql]> select Host,User,Password from user;
23+-----------+------+-------------------------------------------+
24| Host      | User | Password                                  |
25+-----------+------+-------------------------------------------+
26| localhost | root | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
27| 127.0.0.1 | root | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
28| ::1       | root | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
29+-----------+------+-------------------------------------------+
303 rows in set (0.00 sec)
31
32MariaDB [mysql]> 

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码

x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号

《云原生架构师实战》

image-20230107215126971

🍀 个人博客站点

https://onedayxyy.cn/

🍀 语雀

https://www.yuque.com/xyy-onlyone

🍀 csdn

https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎

https://www.zhihu.com/people/foryouone

image-20230107215203185

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!

推荐使用微信支付
微信支付二维码
推荐使用支付宝
支付宝二维码
最新文章

文档导航