共计 1059 个字符,预计需要花费 3 分钟才能阅读完成。
mysql 安装包下载地址
https://dev.mysql.com/downloa…
- centos 默认会装置 mariadb 所以要先卸载一下,防止出现抵触
rpm -qa | grep mariadb
卸载:rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 –nodeps
2. 在 usr/local 下创立 mysql 目录
cd /usr/local&mkdir&&mysql
3. 解压文件
tar -xvf mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar - 装置
rpm -ivh mysql-community-common-8.0.23-1.el7.x86_64.rpm –nodeps –force
rpm -ivh mysql-community-libs-8.0.23-1.el7.x86_64.rpm –nodeps –force
rpm -ivh mysql-community-client-8.0.23-1.el7.x86_64.rpm –nodeps –force
rpm -ivh mysql-community-server-8.0.23-1.el7.x86_64.rpm –nodeps –force
5. 初始化
mysqld –initialize
chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld.service
systemctl enable mysqld
6. 查看数据库明码
cat /var/log/mysqld.log | grep password
7. 登录
mysql -uroot -p
而后输出查看的明码,这边我测试的话用复制过去的明码始终谬误要手动输出能力胜利!算是一个坑点。
8. 批改明码
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘123456’
9. 近程拜访受权
create user ‘root’@’%’identified with mysql_native_password by ‘123456’;
grant all privileges on . to ‘root’@’%’ with grant option;
flush privileges;
10. 重启 mysql 服务
service mysqld restart
11. 凋谢端口
firewall-cmd –zone=public –add-port=3306/tcp –permanent
firewall-cmd –reload
正文完