7q4w1e

1, 关闭mysql服务

/etc/rc.d/init.d/mysqld stop


2,使用 –skip-grant-tables选项启动mysql服务

(1)打开文件 mysqld

vi /etc/rc.d/init.d/mysqld

(2)编辑文件 mysqld,在下面运行启动的语句里增加--skip-grant-tables

/usr/bin/mysqld_safe --skip-grant-tables --datadir="$datadir" --socket="$socketfile"

--log-error="$errlogfile" --pid-file="$mypidfile"

加入--skip-grant-tables的意思是启动mysql服务的时候跳 过权限表认证。启动后,连接到mysql的root不需要口令

 

3,重新启动mysql服务

/etc/rc.d/init.d/mysqld start

 

4,登录mysql

 mysql -u root -h 127.0.0.1 -P3306 -p

备注:直接回车进入就好,此时不输入密码也可以登录mysql

 

5,修改root用户的密码

mysql> select host,user,password from mysql.user;

mysql> update mysql.user set password=password(\'1111\') where user=\'root\';

mysql> flush privileges;

mysql> quit


5, 重新启动mysql,就可以使用 新密码登录了

/etc/rc.d/init.d/mysqld restart   //重新启动mysql

mysql -u root -h 127.0.0.1 -P3306 -p

输入密码:123456

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2021-12-13
  • 2021-12-15
  • 2021-05-09
  • 2021-05-24
  • 2022-01-12
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2021-12-31
  • 2021-12-15
  • 2021-12-20
  • 2021-08-04
  • 2021-10-27
相关资源
相似解决方案