yum -y install cmake
cmake \
-DCMAKE_INSTALL_PREFIX=/u01/mysql \
-DMYSQL_DATADIR=/u01/mysql/data \
-DSYSCONFDIR=/u01/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_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=utf8 \
-DDEFAULT_COLLATION=utf8_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
/*
随机生成的密码:
2016-11-24T09:59:53.588280Z 1 [Note] A temporary password is generated for root@localhost: yuWx:rLGp2xj
之前版本mysql_install_db是在mysql_basedir/script下,5.7放在了mysql_install_db/bin目录下,且已被废弃
“–initialize”会生成一个随机密码(~/.mysql_secret),而”–initialize-insecure”不会生成密码
–datadir目标目录下不能有数据文件
*/
//备份my.conf文件
mv /etc/my.cnf /etc/my.cnf.bak
[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
//配置my.cnf
[root@CnBJYwz01QorasunpengL01 mysql-5.7.10]# vi /u01/mysql/my.cnf
[client]
port = 3306
socket = /u01/mysql/data/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
server-id = 1
user = mysql
port = 3306
socket = /u01/mysql/data/mysql.sock
basedir = /u01/mysql
datadir = /u01/mysql/data
open_files_limit = 10240
back_log = 600
max_connections = 3000
max_connect_errors = 6000
table_open_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
thread_cache_size = 300
query_cache_size = 64M
query_cache_limit = 4M
default-storage-engine = InnoDB
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 256M
max_heap_table_size = 256M
long_query_time = 4
slow_query_log_file=/u01/mysql/data/slow-log.log
slow_query_log
log-bin = /u01/mysql/data/ray-bin.log
binlog_cache_size = 4M
max_binlog_cache_size = 8M
max_binlog_size = 512M
expire_logs_days = 7
key_buffer_size = 256MB
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
skip-name-resolve
lower_case_table_names = 1
innodb_buffer_pool_size = 512M
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
max_allowed_packet = 32M
[mysqld_safe]
log-error=/u01/mysql/data/mysql_ray.err
pid-file=/u01/mysql/data/ray.pid
[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)