CentOS7安装MYSQL8.0(rpm-bundle.tar 版本)
CentOS7安装MYSQL8.0(rpm-bundle.tar 版本)
一 下载MYSQL安装包
百度云盘
提取码:1234
二 修改安装版本(非必须)
- 查看是否存在
rpm -qa|grep mariadb;
- 删除自带的
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
三 开始安装 (自定义目录安装)
1、 解压安装包
tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
2、按照我的顺序安装以下四个包
rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm;
rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm;
rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm;
rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm --force --nodeps;
四 配置MySQL配置文件
vim /etc/my.cnf
8.0跳过登录校验可能会出现问题,这里我就不设置跳过验证了
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
########这里添加##############
character_set_server=utf8
init_connect='SET NAMES utf8'
########这里添加#############
#
# 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 the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_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
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
四 启动服务
设置开机启动
systemctl start mysqld.service
获取MYSQL临时登录密码
grep "password" /var/log/mysqld.log
登录MYSQL
mysql -uroot -p
修改密码
- 修改密码规则
set global validate_password.policy=0;
set global validate_password.length=1;
- 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
- 设置远程登录
select host, user from user;
这个root只允许localhost本地登录,我们修改成为%
update user set host='%' where user ='root';
- 刷新并且重启
flush privileges;
exit;
systemctl restart mysqld.service