Centos8 二进制安装MariaDB-10.2.31
2021/11/30 7:06:29
本文主要是介绍Centos8 二进制安装MariaDB-10.2.31,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1、准备用户并创建存放数据库的文件夹
[root@centos7 ~]#groupadd -r -g 306 mysql [root@centos7 ~]#useradd -r -g 306 -u 306 -d /data/mysql mysql [root@centos7 ~]#mkdir /data/mysql
2、下载安装包并解压到指定的路径
[root@centos7 ~]#tar xf mariadb-10.2.31-linux-systemd-x86_64.tar.gz -C /usr/local/ [root@centos7 ~]#cd /usr/local/ #####创建软链接是为了后续升级数据库方便 [root@centos7 local]#ln -s mariadb-10.2.31-linux-systemd-x86_64/ mysql
3、数据库文件初始化
####注意:要和/etc/init.d/mysqld里面的路径保持一致 [root@centos7 ~]#/usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql --basedir=/usr/local/mysql --user=mysql
4、给相关文件目录赋予权限
[root@centos7 ~]#chown -R mysql.mysql /data/mysql [root@centos7 ~]#chown -R mysql.mysql /usr/local/mariadb* /usr/local/mysql/
5、配置启动数据库的配置文件
[root@centos7 ~]#cat /etc/my.cnf [mysqld] datadir=/data/mysql basedir=/usr/local/mysql socket=/usr/local/mysql/mysql.sock port=3306 pid-file=/usr/local/mysql/mysql.pid [client] socket=/usr/local/mysql/mysql.sock
6、配置数据的启动文件
[root@centos7 ~]#cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@centos7 ~]#sed -Ei 's#^(basedir=)$#\1\/usr\/local\/mysql#' /etc/init.d/mysqld [root@centos7 ~]#sed -Ei 's#^(datadir=)$#\1\/data\/mysql#' /etc/init.d/mysqld
8、PATH路径
[root@centos7 ~]#echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh [root@centos7 ~]#. /etc/profile.d/mysql.sh
9、启动数据库并设置开机启动
[root@centos7 ~]#systemctl start mysql [root@centos7 ~]#chkconfig --add mysqld
10、验证数据库是否编译成功
[root@centos7 ~]#ss -ntulp Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=1369,fd=3)) tcp LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=2270,fd=13)) tcp LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=1667,fd=19)) [root@centos7 ~]#mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.2.31-MariaDB MariaDB Server 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 | | test | +--------------------+ 4 rows in set (0.00 sec)
错误分析:
1、mysql命令找不到
###通常是PATH路径问题 echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh/
2、如下问题
###在配置文件注释该行 [root@centos7 ~]#cat /etc/my.cnf |grep -n "symbolic-links=0" 10:symbolic-links=0
3、缺少相关包
[root@centos7 ~]#yum install libncurses* -y
4、权限问题
[ERROR] Can't start server : Bind on unix socket: Permission denied [ERROR] Do you already have another mysqld server running on socket: [ERROR] /usr/local/mysql/mysql.sock ? Aborting [ERROR] Can't start server : Bind on unix socket: Permission denied [ERROR] Do you already have another mysqld server running on socket: /usr/local/mysql/mysql.sock ? [ERROR] Aborting mysqld_safe mysqld from pid file /usr/local/mysql/mysql.pid ended
[root@centos7 ~]#chown -R mysql.mysql /usr/local/mariadb* /usr/local/mysql*
这篇关于Centos8 二进制安装MariaDB-10.2.31的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16useReducer案例详解:从零开始理解与应用
- 2024-11-15聊聊用LangChain4J构建聊天机器人的那些事儿
- 2024-11-15LangChain 和 LlamaIndex 在检索增强生成(RAG)中的大比拼:全面对比评测
- 2024-11-15平台工程不只是配置管理:超越CFEngine的方法
- 2024-11-152023年KubeCon芝加哥大会精华回顾
- 2024-11-15我花了3小时大致了解了ClickHouse
- 2024-11-15在使用平台私钥进行解密时提示 "私钥解密失败" 错误信息是什么原因?-icode9专业技术文章分享
- 2024-11-15Layui框架有哪些方式引入?-icode9专业技术文章分享
- 2024-11-15Layui框架中有哪些减少对全局环境的污染方法?-icode9专业技术文章分享
- 2024-11-15laydate怎么关闭自动的日期格式校验功能?-icode9专业技术文章分享