Liunx 下MYSQL 5.7 二进制安装
Posted xuege
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Liunx 下MYSQL 5.7 二进制安装相关的知识,希望对你有一定的参考价值。
Linux 下 mysql 5.7 二进制安装
数据库服务器操作系统配置可参看《Linux下MYSQL 5.6 源码安装》https://www.cnblogs.com/doctormo/p/12019550.html
这里采用的是 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz, 可从MySQL官网 https://dev.mysql.com/downloads/mysql 下载5.7 版本。
1.1 安装必要的依赖包
# yum -y install gcc gcc-c++ make cmake automake autoconf libxml2 libxml2-devel zlib zlib-devel ncurses ncurses-devel numactl-devel numactl
1.2 创建目录和授权
# useradd mysql # mkdir -p /data/my3306 # mkdir -p /u02/my3306/data # mkdir -p /u02/my3306/log/iblog # mkdir -p /u02/my3306/log/binlog # mkdir -p /u02/my3306/tmp # mkdir -p /u02/my3306/run # chown -R mysql.mysql /u02
1.3 解压
# cd /usr/local/src ==> mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz上传至此 # tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz # mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/ # cd /usr/local/ # ln -s mysql-5.7.22-linux-glibc2.12-x86_64 mysql # chown -R mysql.mysql /usr/local/mysql
1.4 配置参数文件
# cat /u02/my3306/my.cnf [client] port=3306 socket=/u02/my3306/mysql.sock default-character-set=utf8mb4 [mysql] pid_file=/u02/my3306/run/mysqld.pid [mysqld] character-set-server=utf8mb4 collation-server=utf8mb4_general_ci autocommit=1 general_log=off explicit_defaults_for_timestamp=true lower_case_table_names=1 #symbolic-links=0 #gtid gtid-mode = ON enforce_gtid_consistency = 1 log_slave_updates = 1 #sql_mode sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # system basedir=/usr/local/mysql datadir=/u02/my3306/data max_allowed_packet=1g max_connections=3000 max_user_connections=2800 open_files_limit=65535 pid_file=/u02/my3306/run/mysqld.pid port=3306 server_id=71693306 skip_name_resolve=ON socket=/u02/my3306/run/mysql.sock tmpdir=/u02/my3306/tmp #binlog log_bin=/u02/my3306/log/binlog/binlog binlog_cache_size=32768 binlog_format=row expire_logs_days=14 log_slave_updates=ON max_binlog_cache_size=2147483648 max_binlog_size=524288000 sync_binlog=10 #logging log_error=/u02/my3306/log/error.log slow_query_log_file=/u02/my3306/log/slow.log log_queries_not_using_indexes=0 slow_query_log=1 log_slave_updates=ON log_slow_admin_statements=1 long_query_time=1 group_concat_max_len = 102400 #relay relay_log=/u02/my3306/log/relaylog relay_log_index=/u02/my3306/log/relay.index relay_log_info_file=/u02/my3306/log/relay-log.info #slave slave_load_tmpdir=/u02/my3306/tmp slave_skip_errors=OFF #innodb innodb_data_home_dir=/u02/my3306/log/iblog innodb_log_group_home_dir=/u02/my3306/log/iblog innodb_adaptive_flushing=ON innodb_adaptive_hash_index=ON innodb_autoinc_lock_mode=1 innodb_buffer_pool_instances=8 #default innodb_change_buffering=inserts innodb_checksums=ON innodb_buffer_pool_size= 20G innodb_data_file_path=ibdata1:1G:autoextend innodb_doublewrite=ON innodb_file_format=Barracuda innodb_file_per_table=ON innodb_flush_log_at_trx_commit=1 innodb_flush_method=O_DIRECT innodb_io_capacity=1000 innodb_lock_wait_timeout=10 innodb_log_buffer_size=67108864 innodb_log_file_size=1048576000 innodb_log_files_in_group=4 innodb_max_dirty_pages_pct=60 innodb_open_files=60000 innodb_purge_threads=1 innodb_read_io_threads=4 innodb_stats_on_metadata=OFF innodb_support_xa=ON innodb_use_native_aio=OFF innodb_write_io_threads=10
[mysqld_safe] datadir=/u02/my3306/data
1.5 初始化数据库
# /usr/local/mysql/bin/mysqld --defaults-file=/u02/my3306/my.cnf --initialize --user=\'mysql\' --log_error_verbosity --explicit_defaults_for_timestamp --basedir=/usr/local/mysql --datadir=/u02/my3306/data/
# chown -R mysql.mysql /u02
1.6 启动数据库
$ su - mysql
$ mysqld_safe --defaults-file=/u02/my3306/my.cnf & $ grep passw /u02/my3306/log/error.log 2018-07-10T03:13:40.850685Z 1 [Note] A temporary password is generated for root@localhost: vh2yRx=Pguem $ mysql -uroot -p -S /u02/my3306/run/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 2 Server version: 5.7.22-log Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement. mysql> set password=password(\'xxxxxxx\'); mysql> flush privileges;
以上是关于Liunx 下MYSQL 5.7 二进制安装的主要内容,如果未能解决你的问题,请参考以下文章
MySQLLinux下MySQL 5.55.6和5.7的RPM二进制和源码安装