目录
文章目录
- 目录
- 实验环境
- 实验软件
- 安装相关依赖包
- 做准备用户和数据目录
- 准备数据库目录
- 源码编译安装
- 下载并解压缩源码包
- 源码编译安装mariadb
- 准备环境变量
- 生成数据库文件
- 准备配置文件
- 准备启动脚本,并启动服务
- 安全初始化
- 测试
- 关于我
- 最后
实验环境
centos7.6 1810
mariadb(10.2.19)
实验软件
链接:https://pan.baidu.com/s/1qN4WGr8yvPn2VYrkB5rW9Q?pwd=o9av
提取码:o9av
2024.4.18-实战:源码编译安装mariadb(10.2.19)-2024.4.18(测试成功)
安装相关依赖包
yum -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
做准备用户和数据目录
useradd -r -s /sbin/nologin -d /data/mysql mysql
准备数据库目录
mkdir -p /data/mysql
chown mysql.mysql /data/mysql
源码编译安装
下载并解压缩源码包
tar xvf mariadb-10.2.18.tar.gz
tar xvf mariadb-10.2.19.tar.gz
源码编译安装mariadb
cd mariadb-10.2.19/
cmake . \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/data/mysql/ \
-DSYSCONFDIR=/etc/ \
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
#make && make install
make -j 8 && make install; date
[!TIP]
提示:如果出错,执行rm -f CMakeCache.txt
准备环境变量
echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
生成数据库文件
cd /app/mysql/
/app/mysql/scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql
准备配置文件
cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf
准备启动脚本,并启动服务
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
#chkconfig --list
chkconfig --add mysqld
chkconfig --list
#service mysqld start
systemctl start mysql
安全初始化
mysql_secure_installation
#/usr/local/mysql/bin/mysql_secure_installation
Enter current password for root (enter for none): #默认没密码,这里直接回车
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] #输入n(远程可以登录)
#mysql.sock 使用unix socket登录(只能在本地登录,不能远程登录);
/var/lib/mysql/mysql.sock文件
Change the root password? [Y/n] #输入y
New password: #输入密码:xyy520
Re-enter new password:
Remove anonymous users? [Y/n] #输入y
Disallow root login remotely? [Y/n] #输入y,禁用root远程登录
Remove test database and access to it? [Y/n] #输入y
Reload privilege tables now? [Y/n] #输入y(是否加载权限)
测试
[root@vm-template mysql]#mysql -uroot -pxyy520
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.2.19-MariaDB-log 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)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> select Host,User,Password from user;
+-----------+------+-------------------------------------------+
| Host | User | Password |
+-----------+------+-------------------------------------------+
| localhost | root | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
| 127.0.0.1 | root | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
| ::1 | root | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
+-----------+------+-------------------------------------------+
3 rows in set (0.00 sec)
MariaDB [mysql]>
关于我
我的博客主旨:
- 排版美观,语言精炼;
- 文档即手册,步骤明细,拒绝埋坑,提供源码;
- 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!
🍀 微信二维码
x2675263825 (舍得), qq:2675263825。
🍀 微信公众号
《云原生架构师实战》
🍀 个人博客站点
https://onedayxyy.cn/
🍀 语雀
https://www.yuque.com/xyy-onlyone
🍀 csdn
https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421
🍀 知乎
https://www.zhihu.com/people/foryouone
最后
好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!