MySQL安装

11 篇文章 0 订阅

文章目录

yum安装

[root@server ~]# yum info mariadb-server
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Available Packages
Name         : mariadb-server
Epoch        : 3
Version      : 10.3.11
Release      : 2.module_el8.0.0+35+6f2527ed
Arch         : x86_64
Size         : 16 M
Source       : mariadb-10.3.11-2.module_el8.0.0+35+6f2527ed.src.rpm
Repo         : AppStream
Summary      : The MariaDB server and related files
URL          : http://mariadb.org
License      : GPLv2 with exceptions and LGPLv2 and BSD.
Description  : MariaDB is a multi-user, multi-threaded SQL database server. It is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. This package contains
             : the MariaDB server and some accompanying files and directories.
             : MariaDB is a community developed branch of MySQL.

[root@server ~]# yum -y install mariadb-server

编译安装

  1. 源码文件
[root@client mariadb]# pwd
/root/mariadb
[root@client mariadb]# ll
total 86308
-rw-r--r-- 1 root root  9460071 Feb 14 07:23 cmake-3.17.0-rc1.tar.gz
-rw-r--r-- 1 root root 78915056 Feb  7 23:42 mariadb-10.5.0.tar.gz
  1. 创建mysql用户和组
[root@client mariadb]# useradd -r -M -s /sbin/nologin mysql
  1. 创建安装目录
[root@client mariadb]# mkdir /opt/{cmake,mariadb}
[root@client mariadb]# chown mysql.mysql /opt/mariadb/
  1. 解压源码包
[root@client mariadb]# tar -xf cmake-3.17.0-rc1.tar.gz 
[root@client mariadb]# tar -xf mariadb-10.5.0.tar.gz 
[root@client mariadb]# ll
total 86316
drwxrwxr-x 11 root root     4096 Feb 12 10:32 cmake-3.17.0-rc1
-rw-r--r--  1 root root  9460071 Feb 14 07:23 cmake-3.17.0-rc1.tar.gz
drwxrwxr-x 34 1001 1001     4096 Nov 28 10:19 mariadb-10.5.0
-rw-r--r--  1 root root 78915056 Feb  7 23:42 mariadb-10.5.0.tar.gz
  1. 准备编译环境
[root@client mariadb]# yum -y groupinstall "Development Tools"
  1. 依赖安装
    根据编译错误提示安装对应依赖
  2. 安装cmake
[root@client mariadb]# cd cmake-3.17.0-rc1/
[root@client cmake-3.17.0-rc1]# ./configure --prefix=/opt/cmake/
[root@client cmake-3.17.0-rc1]# echo $?
[root@client cmake-3.17.0-rc1]# make -j 2 && make install -j 2
[root@client cmake-3.17.0-rc1]# echo $?
  1. 添加程序到bin
[root@client cmake-3.17.0-rc1]# cd /opt/cmake/
[root@client cmake]# ln -sv /opt/cmake/bin/* /bin/
'/bin/cmake' -> '/opt/cmake/bin/cmake'
'/bin/cpack' -> '/opt/cmake/bin/cpack'
'/bin/ctest' -> '/opt/cmake/bin/ctest'
[root@client mariadb-10.5.0]# readlink /bin/cmake 
/opt/cmake/bin/cmake
[root@client mariadb-10.5.0]# readlink /bin/cpack 
/opt/cmake/bin/cpack
[root@client mariadb-10.5.0]# readlink /bin/ctest 
/opt/cmake/bin/ctest
  1. 依赖安装
    根据编译错误提示安装对应依赖
  2. 编译mariadb
[root@client cmake]# cd /root/mariadb/mariadb-10.5.0/
[root@client mariadb-10.5.0]# cmake . -DCMAKE_INSTALL_PREFIX=/opt/mariadb -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DWITH_EXTRA_CHARSETS=all -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
[root@client mariadb-10.5.0]# echo $?
[root@client mariadb-10.5.0]# make -j 2 && make install -j 2
[root@client mariadb-10.5.0]# echo $?
  1. 首次运行设置
[root@client mariadb-10.5.0]# cd /opt/mariadb/  #进入目录
[root@client mariadb]# chown -R mysql.mysql /opt/mariadb/  #修改属主属组
[root@client mariadb]# ln -sv /opt/mariadb/bin/* /bin/
[root@client mariadb]# ./scripts/mysql-install-db --basedir=/opt/mariadb/ --datadir=/opt/mariadb/data  #初始化数据库
[root@client mariadb]# chown -R mysql.mysql /opt/mariadb/  #修改属主属组
[root@client mariadb]# ./support-files/mysql.server start  #启动数据库
  1. 设置开机启动
[root@client mariadb]# ln -sv /opt/mariadb/support-files/mysql.server /etc/init.d/mysqld
[root@client mariadb]# chkconfig --add mysqld
[root@client mariadb]# chkconfig on
[root@client mariadb]# chkconfig --list mysqld
[root@client mariadb]# chkconfig --list mysqld

mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值