安装8.0
本人使用的是阿里云服务器, 系统是Aliyun Linux, 也就是centos.
下载地址
https://dev.mysql.com/downloads/repo/yum/
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
yum localinstall mysql80-community-release-el7-2.noarch.rpm
如果已经有其它的mysql源, 可能会出现conflict错误, 需要把旧的源删除掉
rpm -e mysql-community-release
查看yum源中的mysql版本
[root@iZ28bxu3bs3Z ~]# yum repolist all | grep mysql
mysql57-community/x86_64 MySQL 5.7 Community Server disabled
mysql57-community-source MySQL 5.7 Community Server - S disabled
!mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 82
mysql80-community-source MySQL 8.0 Community Server - S disabled
启用mysql 8.0
yum-config-manager --enable mysql80-community
安装
yum install mysql-community-server
运行
service mysqld start
获取登录密码
grep 'temporary password' /var/log/mysqld.log
2019-03-12T05:05:20.587838Z 5 [Note] [MY-010454] [Server]
A temporary password is generated for root@localhost: hM,c;h,4r)u!
mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qW123456!';
参数配置
大部分参数可以通过启动参数
, 配置文件
, 以及通过set
指令来配置
使用启动参数时, 格式为--name=value
的格式, 而通过配置文件
或set
指令配置时, 格式为name=value
查看当前配置的参数
mysql> show variables;
mysql> show variables like "%connection%";
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_connection | utf8mb4 |
| collation_connection | utf8mb4_0900_ai_ci |
| max_connections | 151 |
| max_user_connections | 0 |
| mysqlx_max_connections | 100 |
+--------------------------+--------------------+
修改参数
https://dev.mysql.com/doc/refman/8.0/en/persisted-system-variables.html
mysql> SET PERSIST max_connections = 1000;
mysql> SET @@PERSIST.max_connections = 1000;
如果不加PERSIST
, 下次启动时, 又会恢复到初始状态
PERSIST
之后的参数会保存在/var/lib/mysql/mysqld-auto.cnf
中
5.7升级到8.0
有些参数可能不支持了, 安装8.0之后, 可能无法启动, 可先注释一些可能出问题的配置参数.
启动之后执行
shell> mysql_upgrade -uroot -p123456