CentOS7安装MySQL8

卸载mariadb

# 查看mariadb安装包
rpm -qa | grep mariadb
# 卸载
rpm -e 查看mariadb安装包 --nodeps
  1. 解压
mkdir tmp
tar vxf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar -C ./tmp
  1. 安装
cd tmp
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm
  1. 初始化、授权和开启mysql服务
mysqld --initialize
chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld
  1. 查看root初始密码, 登录修改密码
cat /var/log/mysqld.log | grep password
mysql -u root -p
ALTER USER "root"@"localhost" IDENTIFIED BY "自己的密码";
FLUSH PRIVILEGES;
  1. 允许远程连接
use mysql;
update user set host = '%' where user ='root';
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '自己的密码';
上一篇:# Java 使用 C3P0 链接池操作 MySQL8


下一篇:mysql8.0.x创建用户及授权