MySQL/mariadb源码安装步骤

人分两类,迷人乏味

    • MySQL数据库

MySQL数据库

MySQL/mariadb源码安装步骤:
1:下载好mariadb或者mysql安装包
2:Xshell提前安装好lrzsz命令(yum -y install lrzsz),只有有了这个命令,才能把windows下载的文件或者包发送进Xshell中
3:执行: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
注:该命令为一整串,不可换行不可拆分
4:执行:useradd -r -s /sbin/nologin -d /data/mysql mysql
5:执行:mkdir /data/mysql
6:执行:chown mysql.mysql /data/mysql
7:解压缩包:ls → tar xvf mariadb-10.2.32.tar.gz
8:进到解完压缩的文件目录中ls → cd mariadb-10.2.32/
9:执行:

cd mariadb-10.2.18/ 
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 

10:执行:make -j 8 && make install ;date
11:执行:echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
12:执行:. /etc/profile.d/mysql.sh
13:执行:/app/mysql/scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql

验证数据库是否安装完成:

ll /data/mysql

查看配置文件:

cd /app/mysql/
ls
ls support-files/
ls

执行:echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
执行:. /etc/profile.d/mysql.sh
执行:cd /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 --add mysqld
执行:service mysqld start
执行:mysql_secure_installation

查看压缩包大小:du -sh *

你可能感兴趣的:(MySQL/mariadb源码安装步骤)