1.卸载自带mariadb
rpm -qa|grep mariadb
rpm -e mariadb-libs --nodeps
2.安装依赖
yum install -y cmake gcc gcc-c++ ncurses-devel bison zlib libxml openssl* automake autoconf make libtool bison-devel libaio-devel
3.下载安装包
cd /data/soft
wget https://www.oaroad.com/files/mysql-5.7.31.tar.gz
tar -xf mysql-5.7.31.tar.gz
wget https://www.oaroad.com/files/boost_1_59_0.tar.gz
tar -xf boost_1_59_0.tar.gz
4.预编译
cd /data/soft/mysql-5.7.31
cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql \
-DINSTALL_DATADIR=/data/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=yes \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0 \
-DSYSCONFDIR=/etc \
-DWITH_READLINE=on \
-DWITH_BOOST=/data/soft/boost_1_59_0/
5.编译 && 安装
make
make install
6.创建用户
useradd -s /sbin/nologin mysql -M
chown -R mysql.mysql /data/mysql
7.创建配置文件
cp /etc/my.cnf /etc/my.cnf.bak
vim /etc/my.cnf
[mysqld]
user = mysql
server_id = 1
port = 3306
basedir = /data/mysql
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
log_bin = /data/mysql/logs/mysql-bin
socket = /data/mysql/tmp/mysql.sock
log-error = /data/mysql/logs/mysql-error.log
pid-file = /data/mysql/tmp/mysqld.pid
character-set-server = utf8
local-infile
default_storage_engine = innodb
default_authentication_plugin = mysql_native_password
log_bin_trust_function_creators = 1
slow_query_log = 1
long_query_time = 10
slow_query_log_file = /data/mysql/logs/mysql-slow.log
log-queries-not-using-indexes = 1
log_timestamps = SYSTEM
[client]
port = 3306
socket = /data/mysql/tmp/mysql.sock
#default-character-set = utf-8
8.创建文件
mkdir -p /data/mysql/logs
mkdir -p /data/mysql/tmp
touch /data/mysql/logs/mysql-error.log
touch /data/mysql/tmp/mysqld.pid
chown -R mysql.mysql /data/mysql
9.初始化数据库
/data/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld
vim /etc/profile
export PATH=/data/mysql/bin:$PATH
source /etc/profile
10.启动
chkconfig --add mysqld
/etc/init.d/mysqld start
11.修改root密码
mysql -uroot -p`grep 'root@localhost' /data/mysql/logs/mysql-error.log |awk -F "[: ]" '{print $NF}'`
alter user "root"@"localhost" identified by "123456";
评论