MySQL 5.7的主要特性有:
- 更好的性能:对于多核CPU、固态硬盘、锁有着更好的优化,每秒100W QPS已不再是MySQL的追求,下个版本能否上200W QPS才是吾等用户更关心的
- 更好的InnoDB存储引擎
- 更为健壮的复制功能:复制带来了数据完全不丢失的方案,传统金融客户也可以选择使用MySQL数据库。此外,GTID在线平滑升级也变得可能
- 更好的优化器:优化器代码重构的意义将在这个版本及以后的版本中带来巨大的改进,Oracle官方正在解决MySQL之前最大的难题
- 原生JSON类型的支持
- 更好的地理信息服务支持:InnoDB原生支持地理位置类型,支持GeoJSON,GeoHash特性
- 新增sys库:以后这会是DBA访问最频繁的库
- 不停库可以在线调整innodb_buffer_pool_size的大小
- 可以将死锁信息记录到error log
- 支持对在线某个连接直接查看执行计划
- 支持多源和多线程复制
老实说自己写的脚本还很LOW,用shell 简单实现。以后有时间在改进。
提示本次shell 支持:本脚本只支持centos 7 安装MySQL版本5.7 msyql 自动安装在/usr/local/mysql 目录[root@mysql02 shell]# cat centos_mysql.sh #!/bin/sh ########## #centos7 install mysql5.7 #by xuebao 20180509 ########## #下载 ##下载 提示:本脚本只支持centos 7 安装MySQL版本5.7 #wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-el7-x86_64.tar.gz REMOVE=`rpm -qa | grep -i mariadb-libs` #编译 yum remove $REMOVE -y yum install libaio -y mkdir -p /home/work/software cd /home/work/software #下载 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-el7-x86_64.tar.gz tar xf mysql-5.7.21-el7-x86_64.tar.gz mv mysql-5.7.21-el7-x86_64 mysql mv mysql /usr/local/ useradd -s/sbin/nlogin -M mysql id mysql mkdir /usr/local/mysql/{data,log} chown -R mysql.mysql /usr/local/mysql/ #编辑my.cnf cat << EOF > /etc/my.cnf [client] port = 3306 socket = /tmp/mysql.sock [mysqld] server_id=10 port = 3306 user = mysql character-set-server = utf8mb4 default_storage_engine = innodb log_timestamps = SYSTEM socket = /tmp/mysql.sock basedir = /usr/local/mysql datadir = /usr/local/mysql/data/ pid-file = /usr/local/mysql/data/mysql.pid max_connections = 1000 max_connect_errors = 1000 table_open_cache = 1024 max_allowed_packet = 128M open_files_limit = 65535 log-bin=mysql-bin #####====================================[innodb]============================== innodb_buffer_pool_size = 1024M innodb_file_per_table = 1 innodb_write_io_threads = 4 innodb_read_io_threads = 4 innodb_purge_threads = 2 innodb_flush_log_at_trx_commit = 1 innodb_log_file_size = 512M innodb_log_files_in_group = 2 innodb_log_buffer_size = 16M innodb_max_dirty_pages_pct = 80 innodb_lock_wait_timeout = 30 innodb_data_file_path=ibdata1:1024M:autoextend #####====================================[log]============================== log_error = /usr/local/mysql/log/mysql-error.log slow_query_log = 1 long_query_time = 1 slow_query_log_file = /usr/local/mysql/log/mysql-slow.log sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES EOF #编译 /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp #授权 chown -R mysql:mysql /usr/local/mysql cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql cp /usr/local/mysql/bin/* /usr/local/sbin/ cd /lib/systemd/system wget http://ftp.zxblinux.com:8082/hjgj/mysql.service systemctl daemon-reload ## 启动服务并查看 /etc/init.d/mysql start netstat -lntup|grep mysql grep "password" /usr/local/mysql/log/mysql-error.log
执行脚本成功后显示Mysql 端口
Starting MySQL. SUCCESS! tcp6 0 0 :::3306 :::* LISTEN 3002/mysqld
修改密码
提示因为Mysql 都是随机密码,显示密码:ng>Ylm7gI4X. 就是在@localhost:后面的
2018-05-19T20:14:49.529280+08:00 1 [Note] A temporary password is generated for root@localhost: ng>Ylm7gI4X. 2018-05-19T20:15:08.889341+08:00 2 [Note] Access denied for user 'root'@'localhost' (using password: YES)
使用密码登录数据库(上面 ng>Ylm7gI4X.,每个人随机密码不一样哦)
[root@mysql02 shell]# mysql -uroot -p Enter password: # 修改密码为123456 mysql> alter user 'root'@'localhost' identified by '123456'; Query OK, 0 rows affected (0.00 sec) #刷新 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)