系统:Linux version 3.10.0-862.el7.x86_64
MySQL版本:mysql-5.6.45.tar.gz
yum install -y cmake make gcc gcc-c++ wget ncurses-devel cmake make perl ncurses-devel openssl-devel bison-devel libaio libaio-devel
tar -xvzf mysql-5.6.45.tar.gz
cd mysql-5.6.45/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
make && make install
#创建mysql用户
useradd -s /sbin/nologin mysql
#初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
#创建mysql mariadb目录和mariadb.log文件
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
mkdir /var/lib/mysql
#修改属主属组为mysql
chown -R mysql:mysql /var/lib/mysql
#修改 my.cnf 配置文件 指定 datadir路径
#修改datadir
vim /usr/local/mysql/my.cnf
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
#修改datadir
datadir = /usr/local/mysql/data
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#添加service服务管理
\cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
#启动MySQL
service mysqld start