一、基础环境
二、安装MySQL
1、卸载mariadb数据库
rpm -qa | grep mariadb
yum -y remove mariadb-libs-5.5.52-1.el7.x86_64
2、安装相关依赖(本文使用CentOS 7.3镜像做本地离线yum源)
yum -y install openssl-devel perl-JSON
3、解压安装MySQL
tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-*.rpm
4、修改配置文件
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、初始化数据库并启动
mysqld --initialize
chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld
systemctl enable mysqld
6、查看临时密码并通过临时密码修改MySQL密码
cat /var/log/mysqld.log | grep password
mysqladmin -uroot -pbga/.tkZw4q! password Test1212!
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登录时密码,防止本机登录失败
mysql -uroot -p -h 192.168.0.101
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test1212!';
flush privileges;
9、修改加密规则
MySql8.0版本和5.0的加密规则不一样,而现在的可视化工具只支持旧的加密方式,如果不修改的话可视化工具可能打不开数据库
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
flush privileges;
精彩专题分享:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。