yum install gcc gcc-c++ openssl openssl-devel ncurses ncurses-devel bison libgcrypt perl make cmake
cd /data/install
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.29.tar.gz
tar xvf mysql-boost-5.7.29.tar.gz
cd mysql-5.7.29
cmake -DCMAKE_INSTALL_PREFIX=/data/software/mysql \
-DMYSQL_DATADIR=/data/mysqldata \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_BOOST=boost
make
make install
创建用户:
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
chown -R mysql.mysql /data/mysqldata
chown -R mysql.mysql /data/software/mysql
初始化数据:
mysqld --initialize-insecure --user=mysql --basedir=/data/software/mysql --datadir=/data/mysqldata
vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
user = mysql
basedir = /data/software/mysql
datadir = /data/mysqldata
pid-file = /data/mysqldata/mysql.pid
log_error = /data/mysqldata/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysqldata/mysql-slow.log
skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1024M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000
explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
log_bin=mysql-bin
binlog_format=mixed
server_id = 232
expire_logs_days = 10
early-plugin-load = ""
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_buffer_pool_size = 128M
innodb_log_file_size = 32M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
设置环境变量PATH:
vim /etc/profile
加入: export PATH=$PATH:/data/software/mysql/bin
加入sysctl管理:
cp /data/software/mysql/support-files/mysql.server /etc/init.d/mysqld
启动:
service mysqld start
登录mysql,修改root密码:
set password for 'root'@'localhost' = password('jiecao123');
网友评论