一、基础环境
1、操作系统:CentOS 7.3
2、MySQL:8.0.13 链接: https://pan.baidu.com/s/13-j_umr7eEnKFaugw4YTqQ 提取码: 62yt
二、安装MySQL
1、卸载mariadb数据库
1
2
|
rpm -qa | grep mariadb yum -y remove mariadb-libs-5.5.52-1.el7.x86_64 |
2、安装相关依赖(本文使用CentOS 7.3镜像做本地离线yum源)
1
|
yum -y install openssl-devel perl-JSON |
3、解压安装MySQL
1
2
3
|
tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle. tar rpm -ivh mysql-community-*.rpm |
4、修改配置文件
1
2
3
4
5
6
7
8
|
vim /etc/my .cnf default-storage-engine = innodb innodb_file_per_table collation-server = utf8_general_ci init-connect = 'SET NAMES utf8' character- set -server = utf8 max_allowed_packet = 100M |
5、初始化数据库并启动
1
2
3
4
|
mysqld --initialize chown mysql:mysql /var/lib/mysql -R systemctl start mysqld systemctl enable mysqld |
6、查看临时密码并通过临时密码修改MySQL密码
1
2
3
|
cat /var/log/mysqld .log | grep password mysqladmin -uroot -pbga/.tkZw4q! password Test1212! |
7、赋远程用户权限
1
2
3
4
5
6
7
|
mysql -u root -p create user 'root' @ '%' identified with mysql_native_password by 'Test1212!' ; grant all privileges on *.* to 'root' @ '%' with grant option; flush privileges; |
8、修改localhost登录时密码,防止本机登录失败
1
2
3
4
5
|
mysql -uroot -p -h 192.168.0.101 ALTER USER 'root' @ 'localhost' IDENTIFIED BY 'Test1212!' ; flush privileges; |
9、修改加密规则
MySql8.0版本和5.0的加密规则不一样,而现在的可视化工具只支持旧的加密方式,如果不修改的话可视化工具可能打不开数据库
1
2
3
|
ALTER USER 'root' @ 'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER; flush privileges; |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/ywd1992/article/details/83862466