首页 > 数据库 > MySQL > mysql 5.7单实例安装
http://www.boost.org/users/download/
mkdir /usr/local/mysql/boost -p [root@localhost ~]# cp boost_1_59_0/* /usr/local/mysql/boost/ -r yum -y install cmake yum -y install gcc* yum -y install ncurses-devel yum -y install gcc-c++ ncurses ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison openssl-devel useradd mysql cmake \ -DCMAKE_INSTALL_PREFIX=/u01/mysql \ -DMYSQL_DATADIR=/u01/mysql/data \ -DSYSCONFDIR=/u01/mysql/data \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_USER=mysql \ -DMYSQL_UNIX_ADDR=/u01/mysql/data/mysql.sock \ -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/u01/mysql/boost 或者默认路径安装 cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_USER=mysql \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/mysql/boost
make && make install
//初始化mysql数据库
/u01/mysql/bin/mysqld --initialize --user=mysql --basedir=/u01/mysql --datadir=/u01/mysql/data --innodb_undo_tablespaces=4 --explicit_defaults_for_timestamp
[root@CnBJYwz01QorasunpengL01 mysql-5.7.10]# cp /u01/mysql/support-files/mysql.server /etc/init.d/mysqld [root@CnBJYwz01QorasunpengL01 mysql-5.7.10]# chmod +x /etc/init.d/mysqld
[root@CnBJYwz01QorasunpengL01 mysql-5.7.10]# vi /u01/mysql/my.cnf [client] port = 3306 socket = /var/lib/mysql/mysql.sock [mysql] no-auto-rehash [mysqld] server-id = 1 user = mysql port = 3306 socket = /var/lib/mysql/mysql.sock basedir = /usr/local/mysql datadir = /usr/local/mysql/data character_set_server = utf8mb4 explicit_defaults_for_timestamp = true #connect options back_log = 100 #requests can be stored on the stack for a short time before MySQL temporarily stops answering new requests max_connections = 1000 max_connect_errors = 10 #number which allow to connect server for error password connect_timeout=20 #The number of seconds that the mysqld server waits for a connect packet max_allowed_packet = 16M ### Table Cache Settings table_open_cache = 1024 ## Range: 64~ 524288,default 64.The recommendation is the same as MAX_CONNECTION or slightly larger than MAX_CONNECTION. open_files_limit = 5000 ##using the bigger value-- max_connections*5 or ulimited -n tmp_table_size = 64M #default 16M,recomendation 64-256M max_heap_table_size = 128M ### Per-Thread Buffers sort_buffer_size = 2M #read_buffer_size = 2M #read_rnd_buffer_size = 16M #bulk_insert_buffer_size = 64M #join_buffer_size = 2M thread_stack = 512K #slow log slow_query_log_file = /usr/local/mysql/data/slow-log.log slow_query_log=1 log_queries_not_using_indexes = 1 log_throttle_queries_not_using_indexes = 5 log_slow_slave_statements = 1 long_query_time = 3 min_examined_row_limit = 100 ##bin log log-bin = /usr/local/mysql/data/log-bin.log binlog_cache_size = 1M #max_binlog_size = 4GG expire_logs_days = 7 binlog_format = ROW #binlog_stmt_cache_size = 10M #key_buffer_size = 256MB lower_case_table_names = 1 #slave log option log_slave_updates relay_log_recovery = 1 slave_skip_errors = ddl_exist_errors #一般设置物理存储的60% ~ 70% innodb_buffer_pool_size = 1G ###innodb options #innodb_buffer_pool_instances = 4 innodb_file_per_table = on #innodb_read_io_threads = 8 ##default 4, #innodb_write_io_threads = 8 autocommit = 0 #turn off auto commit innodb_flush_method = O_DIRECT ##innodb memery innodb_buffer_pool_size = 512M #70%-80% of momery #innodb_max_dirty_pages_pct = 70 #innodb_lock_wait_timeout = 120 ##redo log #设置redoLog文件所在目录, redoLog记录事务具体操作内容 innodb_log_group_home_dir = /usr/local/mysql/data/ innodb_log_buffer_size = 16M #default 8M, 16-64M is better innodb_log_file_size = 256M innodb_log_files_in_group = 4 innodb_flush_log_at_trx_commit = 2 sync_binlog = 1 #set independent undo innodb_undo_directory = /usr/local/mysql/data innodb_undo_logs = 128 innodb_undo_tablespaces = 4 innodb_max_undo_log_size = 1G #innodb_purge_rseg_truncate_frequency = 128 #default 128 innodb_undo_log_truncate = 1 [ysqldump] quick max_allowed_packet = 32M [mysqld_safe] log-error=/usr/local/mysql/data/mysql.err pid-file=/usr/local/mysql/data/mysql.pid
[Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql Type=forking # Start main service ExecStart=/usr/local/mysql/support-files/mysql.server start #ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf # Stop main service ExecStop=/usr/local/mysql/support-files/mysql.server stop LimitNOFILE = 5000
[mysql@CnBJYwz01QorasunpengL01 mysql]$ service mysqld start
Starting MySQL.. [ OK ]
//重置密码
[mysql@CnBJYwz01QorasunpengL01 ~]$ mysql -uroot -pyuWx:rLGp2xj
mysql> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.01 sec)来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28572479/viewspace-2132709/ ,如需转载,请注明出处,否则将追究法律责任。