Linux版本:CentOS7.6
MySQL版本:8.0.13
1、下载MySQL8
2、安装MySQL8
登陆root用户。
上传安装包到服务器(或者可以在服务器直接使用wget命令进行下载),并解压。
卸载mariadb,会与MySQL安装冲突。
rpm -qa | grep mariadb查看有无mariadb
如果有则删除yum -y remove mariadb-libs.x86_64
安装numactl
yum list installed|grep numactl
如果没有则yum install numactl,否则会在安装时报错
error:
Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-8.0.13-1.el7.x86_64
解压tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
安装4个必须安装的包(需要按顺序安装)。
rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm
安装另外4个非必须包(需要按顺序安装也可以不装跳过此步骤)。
rpm -ivh mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-test-8.0.13-1.el7.x86_64.rpm
启动service mysqld start并查看状态service mysqld status
3、登陆MySQL8
查看临时密码cat /var/log/mysqld.log
查看临时密码
使用临时密码登陆并修改密码。
mysql -u root -p回车输入临时密码。
alter USER 'root'@'localhost' IDENTIFIED BY '新密码(必须包含:数字大小写字母特殊字符)';
修改MySQL的root用户远程可以登陆
use mysql;
select host, user from user;
如果host为localhost则执行update user set host = "%" where user='root';
刷新生效flush privileges;
解决部分客户端无法连接的问题,比如dbvisualizer报
Unable to load authentication plugin 'caching_sha2_password
mysql -u root -p回车输入密码。
alter USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root用户的密码';
刷新生效flush privileges;
4、更改时区
1.查看当前时间。
select now() from dual;
2.如果发现和当前系统时间不一致,则需要根据实际情况来修改。
set persist time_zone='-5:00';
flush privileges;
3.查看修改后的时区和当前时间
show variables like '%time_zone%';
select now() from dual;
参考文章