1、知道密码

  第一次登陆(无密码)

mysqladmin -u root password NEWPASSWORD 

  修改过密码

mysqladmin -u root -p 'oldpassword' password 'newpassword'

2、忘记密码

  编辑MySQL配置文件my.cnf

vi /etc/my.cnf 

  #编辑文件,找到[mysqld],在下面添加一行skip-grant-tables

[mysqld]
skip-grant-tables

  重启服务

service mysqld restart

  进入MySQL控制台修改密码

mysql -uroot -p
update mysql.user set password=password('123123') where User="root" and Host="localhost";
flush privileges; #刷新系统授权表

  取消/etc/my.cnf中的skip-grant-tables并重启mysql

3、开启远程访问权限

  进入mysql控制台

grant all privileges on *.* to 'root'@'10.13.32.60' identified by '123123' with grant option;
flush privileges; 
exit

  上面的是开启的IP 192.168.0.1的,如要开启所有的,用%代替IP

##取消授权等操作 查看

相关文章:

  • 2022-03-04
  • 2022-01-07
  • 2021-08-20
  • 2021-12-16
  • 2021-12-18
  • 2022-12-23
  • 2021-12-16
  • 2021-12-06
猜你喜欢
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2021-09-08
  • 2021-09-24
  • 2021-04-17
相关资源
相似解决方案