Mairadb-源码编译安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mairadb-源码编译安装相关的知识,希望对你有一定的参考价值。
源码编译安装Mairadb1.先安装环境所需要的依赖组件
[[email protected] ~]# yum -y install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutlsevel libxml2-devel openssl-devel libevent-devel libaio-devel
2.创建所需的要的用户
[[email protected] ~]#useradd -r -s /sbin/nologin -d /data/mysql mysql
3.创建数据存放目录,并修改属主属组为mysql用户
[[email protected] ~]#mkdir /data/mysql
[[email protected] ~]#chown -R mysql.mysql /data/mysql/
4.把下载好的源码包上传到服务器上,这里用到的版本号为mariadb-10.2.23、上传好之后解压源码包
[[email protected] ~]#tar xf mariadb-10.2.23.tar.gz
[[email protected] ~]#du -sh mariadb-10.2.23.tar.gz mariadb-10.2.23
69M mariadb-10.2.23.tar.gz
507M mariadb-10.2.23
5.进到mariadb解压目录里,开始编译安装mariadb
[[email protected] ~]#cd mariadb-10.2.23
[[email protected] ~/mariadb-10.2.23]#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 -j 4 使用CPU多线程 不过需要看CPU的实际核心数来
[[email protected] ~/mariadb-10.2.23]#make -j 4 && make install
6.初始化数据库
[[email protected] /app/mysql]#scripts/mysql_install_db --user=mysql --datadir=/data/mysql
7.查看数据存放目录是否已经生成文件和目录
[[email protected] /app/mysql]#ls /data/mysql/ -l
total 110620
-rw-rw---- 1 mysql mysql 16384 May 2 11:34 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 May 2 11:34 aria_log_control
-rw-rw---- 1 mysql mysql 938 May 2 11:34 ib_buffer_pool
-rw-rw---- 1 mysql mysql 12582912 May 2 11:34 ibdata1
-rw-rw---- 1 mysql mysql 50331648 May 2 11:34 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 May 2 11:34 ib_logfile1
drwx------ 2 mysql root 4096 May 2 11:34 mysql
drwx------ 2 mysql mysql 20 May 2 11:34 performance_schema
drwx------ 2 mysql root 6 May 2 11:34 test
8.配置mariadb的环境变量
[[email protected] /app/mysql]#vim /etc/profile.d/mysql.sh
export PATH=/app/mysql/bin:$PATH
[[email protected] /app/mysql]#. /etc/profile.d/mysql.sh
9.拷贝系统模版配置文件到/etc下改名为my.cnf,把系统自带的覆盖掉
[[email protected] /app/mysql]#cp support-files/my-huge.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
10.拷贝mariadb启动脚本到/etc/init.d/下命名为mysqld、并添加到开机启动项里,然后启动服务
[[email protected] /app/mysql]#cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] /app/mysql]#chkconfig --add mysqld
[[email protected] /app/mysqlservice mysqld start
Starting mysqld (via systemctl): [ OK ]
11.进入到maridb数据库操作界面里
[[email protected] ~]#mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.2.23-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 |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]>
到此数据库就安装完成了,后面就可以登录到数据库里面进行一系列的操作了
以上是关于Mairadb-源码编译安装的主要内容,如果未能解决你的问题,请参考以下文章
centos-7yum安装(mairadb)实现mysql多实例
Android 插件化VirtualApp 源码分析 ( 目前的 API 现状 | 安装应用源码分析 | 安装按钮执行的操作 | 返回到 HomeActivity 执行的操作 )(代码片段