安装yum源
yum install http://repo.mysql.com/mysql57-community-release-el7.rpm
检测老版本
rpm -qa | egrep "mariadb|mysql" #查看是系统否存在老版本的mysql
若有删掉
rpm -e mariadb* --nodeps
安装mysql57
yum install mysql-server -y #开始安装mysql
systemctl start mysqld
第一次安装的时候,
cat /var/log/mysqld.log | grep password
查看到默认密码
复制后,用默认密码登陆
然后第一次登陆后,用alter user 改密码,默认8位数以上,有大小写,有标点
alter user root@localhost identified by 'xxxxxxxxx';
查看密码等级
show variables like 'validate_password%';
然后修改密码等级,
set global validate_password_policy = 0;
//只是检测密码位数,LOW,不在限制大小混等
初始化安全向导
mysql_secure_installation
-------------------------------------------------------------------------------------------------
如果碰到performance_schema.session_variables 不存在,
performance_schema在mysql5.5以上就有自带
performance_schema(安装数据库时自带的)如果装数据库或者使用数据时不小心删除了,就会出现Table‘performance_schema.session_variables’ doesn’t exist的异常。
解决方式:
第一步:
# mysql_upgrade -uroot -p
第二步:
# systemctl stop mysqld
# systemctl start mysqld
-----------------------------------------------------------
然后加入自启动
systemctl enable mysqld
systemctl restart mysql
进入后 用status查看版本状态等。
修改vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
collation-server=utf8_general_ci
performance_schema_max_table_instances=400
table_definition_cache=400
table_open_cache=256
wait_timeout=5184000
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#default-character-set=utf8 这句话在5.6上没报错,但在5.7版本,报错。需要注释掉。
[mysql.server]
default-character-set=utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8
show global variables like 'wait_timeout';
show variables like 'character%';