Linux(七)Centos7下安装mysql5.7

一、在线安装mysql5.7

1、卸载centos7 自带的Mariadb

查看已装mariadb:rpm -qa | grep Mariadb
卸载:rpm -e “mariadb包名” 强制卸载:rpm -e --nodeps "mariadb包名"
验证:rpm -qa | grep Mariadb

2、cd进入希望保存的目录,下载mysql5.7 rpm包

wget -c https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

3、安装mysql5.7源

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

4、安装mysql

yum list | grep mysql可以查看仓库中能够安装的mysql包
安装
yum install mysql-server

====================【下面插播一条报错信息】======================
image.png

执行这条命令时小插曲:

image.png
报错说没有这个包,那就手动去准备
执行这条命令:
rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
安装完成后再次执行:yum install mysql-server
若还是报刚才那个错,重启一下服务器 shutdown -r now
image.png
安装成功
指导博客:https://blog.csdn.net/weixin_42045591/article/details/87447909

5、启动mysql、查看状态

systemctl start mysqld
systemctl status mysqld
systemctl stop mysqld 停止服务
systemctl restart mysqld 重启服务器


image.png

6、查看默认密码

grep 'temporary password' /var/log/mysqld.log
image.png

方法二、跳过密码
停止服务
在/etc/my.cnf 添加最后

skip-grant-tables
image.png

7、登录mysql

mysql -u root -p
切换到mysql库
修改root用户密码
use mysql;

image.png

update user set password="你的密码" where User = 'root';
5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string
update user set authentication_string="你的密码" where User = 'root';
刷新授权
flush privileges;
退出mysql:exit
重启mysql
用刚设置的密码登录mysql
指导博客:https://www.cnblogs.com/boris-et/p/8316953.html

二、远程Navicat连接mysql

1、登录mysql

2、切换到mysql库

use mysql;

3、配置远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; 

flush privileges;


image.png

image.png

远程Navicat链接成功
指导博客:https://blog.csdn.net/dongzi_yu/article/details/105004013
踩了很多很多坑,终于爬出来了
image.png

持续学习中!!!!!!!!
头秃,头秃,头秃

你可能感兴趣的:(Linux(七)Centos7下安装mysql5.7)