您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
今天在CentOS 6.5上安装mysql5.7时遇到一个问题,没有初始化密码。
在mysql5.7之前的版本首次登陆是无需密码的,但是5.7起会生成一个初始化密码/root/.mysql_secert
cat /root/.mysql_secert 就可以查看初始化密码了
但是我的安装没有发现.mysql_secert文件。
这种情况的解决方案:
mysqld_safe --user=mysql --skip-grant-tables & #跳过授权验证方式启动mysqlmysql -uroot -p>use mysql;>desc user; #发现没有了password这个密码参数...略| authentication_string | text | YES | | NULL | || password_expired | enum('N','Y') | NO | | N | || password_last_changed | timestamp | YES | | NULL | || password_lifetime | smallint(5) unsigned | YES | | NULL | || account_locked | enum('N','Y') | NO | | N | |+------------------------+-----------------------------------+------+-----+-----------------------+-------+>select user,host,authentication_string,password_expired from user;+-----------+-----------+-------------------------------------------+------------------+| user | host | authentication_string | password_expired |+-----------+-----------+-------------------------------------------+------------------+| root | localhost | *9AA01F6E2A80A823ACB72CC07337E2911404B5B8 | Y || mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |+-----------+-----------+-------------------------------------------+------------------+#到这里不难发现root账户的密码已过期,还比5.6多出了一个mysql.sys用户>update user set authentication_string=password('123456') where user='root';#修改密码为123456>flush privileges;重新登录mysql,首先停掉所有mysql进程
mysqld_safe --user=mysql &mysql -uroot -p>show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.#报错,需要使用alter user 修改密码,所以登陆进来的第一件事情是修改mysql的初始密码。否则使用会报错> alter user root@'localhost' identified by 'aolens123..';#这下就好了
可以看到5.7的密码字段改成了authentication_string,
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。