Home > Database > Mysql Tutorial > body text

Mysql5.7全新的root密码规则_MySQL

WBOY
Release: 2016-06-01 11:52:23
Original
1184 people have browsed it

今天在安装mysql5.7.8的时候遇到一些问题,首当其冲便的是初始root密码的变更,特分享解决方法如下:

1.mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。

shell> cat /root/.mysql_secret

# Password set for user 'root@localhost' at 2015-04-22 22:13:23

?G5W&tz1z.cN

2.若第一步成功,则使用该密码继续第7步(笔者由于找不到该文件,只能从第3步开始)

3.修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables

4.service mysqld restart后,即可直接用mysql进入

5.mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

mysql> flush privileges;

mysql> quit;

6.将/etc/my.cnf文件还原,重新启动mysql:service mysql restart,这个时候可以使用mysql -u root -p'123qwe'进入了

7.mysql>SET PASSWORD = PASSWORD('newpasswd'); 设置新密码

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template