MySQL 8.0之后版本密码修改


MySQL刚刚安装完毕时

  • mysqld --initialize
  • grep password /var/log/mysqld.log 获取临时密码
  • mysql -uroot -p 输入临时密码登录MySQL
  • alter user 'root'@'localhost' identified by 'new@password';
  • 如果忘记或者丢失了临时密码, 重新使用mysqld --initialize

MySQL在使用中修饰了密码

  • mysqld --user=mysql --skip-grant-tables &
  • mysql -uroot 登录MySQL
  • flush privileges; # 否则无法使用对用户操作的命令
  • alter user 'root'@'localhost' identified by 'new@password'; # 这样是不可以的, 会报错, 不可以对root用户修改密码, 我们只好创建一个新的有超级管理权限的用户
  • create user 'admin'@'localhost' identified by 'new@password'; # 先创建一个普通的admin用户
  • grant all on . 'admin'@'localhost'; # 赋予admin用户所有权限


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM