RHEL7_mysql5.7.17_安装初始登录


rh开发云主机域名el7.2x64server上,以yum方式安装完mysql5.7.17后。

执行mysql-uroot-p命令,此时并不知道root密码是什么。

[root@localhostbin]#mysql-uroot-p

Enterpassword:

ERROR1045(28000):Accessdeniedforuser’root’@’localhost'(usingpassword:YES)

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

相关推荐: MySQL延时复制简介

公司有一套mysqlAB复制架构的生产库,一主一从的架构, 每周一凌晨0天都自动做全备。 一切正常,但今天(假设为周6)不小心误删除了一张表,从库也会跟着做误删除。假设这张表里有好几年的业务数据, 如何恢复呢? 有以下几种思路: 需要把这几年内所有的二进制日志…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 06/05 17:26
下一篇 06/05 17:26

相关推荐