centos 新安装mysql-server,跳过密码登录,修改root密码

安装yum源

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm

安装 mysql-community-server

yum -y install mysql-community-server

可能会报错

The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.

解决

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

mysql -u root -p 需要密码

mysql -u root 报错 怎么解决

修改MySQL的登录设置:

vi /etc/my.cnf

在[mysqld]的段中加上一句:skip-grant-tables

例如:

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

skip-grant-tables

保存并且退出vi。

systemctl restart mysqld

vim /etc/my.cnf
skip-grant-tables
wq!
systemctl restart mysqld

mysql -u root -p
直接回车,跳过密码登录成功
#刷新权限
flush privileges;

#修改密码
set password for root@localhost='1';
exit

vim /etc/my.cnf
#skip-grant-tables
wq!
systemctl restart mysqld

mysql -u root -p
输入密码登录成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值