-
安装编译环境
- RHEL, CentOS, Fedora操作系统
yum groupinstall "Development Tools" "Server Platform" -y
yum -y install gcc gcc-c++ make cmake ncurses ncurses-devel libxml2 libxml2-devel openssl-devel bison bison-devel
-
创建系统用户
groupadd -r mysql
useradd -r -s /sbin/nologin -g mysql mysql
-
创建MariaDB数据目录
cd /
mkdir /data/mysql
chown mysql:mysql /data/mysql
-
CMake安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/mysql -DMYSQL_USER=mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITHOUT_MROONGA_STORAGE_ENGINE=1
-
修改目录权限
chown -R root:mysql /usr/local/mysql
-
导出文件
- 导出可执行文件:
echo "export PATH=$PATH:/usr/local/mysql/bin" /etc/profile.d/mysql.sh
- 导出头文件:
ln -sv /usr/local/mysql/include /usr/local/mysql
- 导出库文件:
echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
- 导出帮助手册:
1. vim /etc/man.config/man_db.conf 在MANPATH_MAP区域添加 MANPATH_MAP /usr/local/mysql/bin /usr/local/mysql/man 2. `mandb`更新帮助手册
- 导出可执行文件:
-
退出再登入
-
处理mysql配置文件
cd /usr/local/mysql
# 注意: 所有的操作都要在该目录进行cp ./support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
, 在[mysqld]域中添加
skip_name_reslove = on innodb_file_per_table = on
echo "192.168.1.150 computer_name" >> /etc/hosts
# 这里192.168.1.150改成你的计算机在内网中的IP, computer_name改成你的hostname
-
创建日志文件(注意权限)
touch /var/log/mariadb/mariadb.log
chmod mysql:mysql /var/log/mariadb/mariadb.log
-
执行安装数据库的脚本install_db
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
-
处理mysql服务启动文件
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service start mysqld
-
执行安全安装
mysql_secure_installation