RHEL7_mysql5.7.17_安装初始登录
在rhel7.2x64server上,以yum方式安装完mysql5.7.17后。
执行mysql-uroot-p命令,此时并不知道root密码是什么。
[root@localhostbin]#mysql-uroot-p
Enterpassword:
ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)
2详细步骤操作Mysql安装完成后临时密码存于/var/log/mysqld.log文件中。获取自动生成的临时密码
[root@localhostbin]#grep"password"/var/log/mysqld.log
2016-12-26T05:36:59.714175Z1[Note]Atemporarypasswordisgeneratedforroot@localhost:tw=gB-DvY4CI
跳过root临时密码登录数据库修改密码
1.Stopmysql:systemctlstopmysqld
2.SetthemySQLenvironmentoption
systemctlset-environmentMYSQLD_OPTS="--skip-grant-tables"
3.Startmysqlusigtheoptionsyoujustset
systemctlstartmysqld
4.Loginasroot
mysql-uroot
5.Updatetherootuserpasswordwiththesemysqlcommands
mysql>UPDATEmysql.userSETauthentication_string=PASSWORD('MyNewPassword')WHEREUser='root'ANDHost='localhost';
mysql>FLUSHPRIVILEGES;
mysql>quit
6.Stopmysql
systemctlstopmysqld
7.UnsetthemySQLenvitromentoptionsoitstartsnormallynexttime
systemctlunset-environmentMYSQLD_OPTS
8.Startmysqlnormally:
systemctlstartmysqld
9.Trytologinusingyournewpassword:
mysql-uroot-p
3资料参考引用mysql5.7mysqld_safecommandnotfoundhttp://www.th7.cn/db/mysql/201610/210252.shtml声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。