如何修改mysql中mysql root用户密码的密码

您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
如何修改mysql用户密码(How do I change the MySQL user password).doc 10页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
需要金币:200 &&
如何修改mysql用户密码(How do I change the MySQL user password)
你可能关注的文档:
··········
··········
如何修改mysql用户密码(How do I change the MySQL user password)
Forgetting the MySQL ROOT password is a common problem in MySQ usage, but a lot of friends don't reset the ROOT password. This often happens: 1045-Acess, denied, for, user:'root'@'localhost'(Using, password:YES) and the like. The following reprint article said how to change the password method.
1. Edit the configuration file for MySQL: my.ini
In the MySQL installation directory, there is a configuration file for my.ini, or MySQL.
At the end of this configuration file, add the following line:
Skip-grant-tables
Save exit editor.
2, and then restart the MySQL service
Execute under command line:
Net stop MySQL
Net start MySQL
3, set the new ROOT password
Then execute it on the command line:
MySQL, -u, root, -p, MySQL, or MySQL -u root -p
Enter directly without a password to enter the database.
At this point, execute use MySQL un
Now let's execute the following statement to update the root code to:
Update, user, set, password=PASSWORD (&root&), where, user='root';
(Note: at this point, do not use mysqladmin -u root -p password 'your new password'. This command modifies the password because'skip-grant-tables'is configured,
If you don't believe it, you can try it. It will definitely report the error shown below:
F:\Documents, and, Settings\long&mysqladmin, -u, root, -p, password,'root'
Enter password:
Warning:, single, quotes, were, not, trimmed, from, the, password,, by, your, command
Line, client, as, you, might, have, expected.
Mysqladmin:
You, cannot, use,'password', command, as, mysqld, runs
With, grant, tables, disabled (was, started, with, --skip-grant-tables)
&Use: mysqladmin flush-privileges password * instead)
Exit quit MySQL.
4 restore the configuration file and restart the service
Then modify the MySQL configuration file and delete the line'skip-grant-tables'just added.
Again, restart the MySQL service, password changes completed.
Try it with the new password root, and
正在加载中,请稍后...操作系统是windows,MySQL版本是 5.7,my.ini在另外的路径下。
已经用了一段时间,也设置了好几个用户,因为要最近想修改root密码,所以用网上的:
mysqladmin -uroot -pmy_old_pwd password my_new_pwd
来修改密码,重启服务后,发现没有修改成功。又试了几次,包括直接update mysql.user,都不成功,结果后来再试时,出现如下出错信息:
mysqladmin: connect to server at 'localhost' failed.
于是找到MySQL 5.7的官方文档:http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
按照如下步骤:
1. 修改 my.ini,在 [mysqld]下增加一行:
skip-grant-tables
2. 重启 mysql
3. 在mysql/bin目录下,执行mysql -uroot,连接上mysql
4. 参考上面官方首次,
&&
&& 5.7.6之后版本用如下命令:
&& ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
&& 运行后出如下信息,说明没成功
&& Query OK, 0 rows affected (0.00 sec)
&& 于是在用5.7.5之前版本的命令:
&& SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
&& 运行后出如下信息,说明也没成功
&& Query OK, 0 rows affected (0.00 sec)
5. 再用如下命令测试:
&&& UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass') password_expired = 'N'
&&& WHERE User = 'root' AND Host = 'localhost';
&&& 运行后也是: Query OK, 0 rows affected
&&& 所以下面的也就不用执行了
&&& FLUSH PRIVILEGES;
6. 接着用如下命令,放宽where条件
&& update mysql.user set authentication_string=PASSWORD('newpassword') where User='root';
&& 执行后提示:Query OK, 1 row affected...说明有戏
7. 将my.ini 修改回来,重启mysql,做测试:root用户新密码可用了,旧密码不再可用。其他用户没有受到影响。
浏览: 228061 次
来自: 深圳
如果你maven项目分了模块,比如分了一个 projec-da ...
yangcheng33 写道赞,有个地方要纠正下 &in ...
赞,有个地方要纠正下 &includes&
学习了。http://surenpi.com
非常棒,因为从来没写过日志,要几小时上手,官网将的一塌糊涂。这 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'Windows下mysql修改root密码的4种方法
转载 & & 投稿:lijiao
这篇文章主要介绍了windows下mysql修改root密码的4种方法,大家可以根据的自己的实际情况进行选择,感兴趣的小伙伴们可以参考一下
MySQL是一个关系型数据库管理系统,在 WEB 应用方面 MySQL 是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。搭配 PHP 和 Apache 可组成良好的开发环境。因此用的很广泛。很多人都会遇到MySQL需要修改密码的情况,比如密码太简单、忘记密码等等。这里我就教大家几种修改MySQL密码的方法。这里以修改root密码为例,操作系统为windows。
先要声明一点,大部分情况下,修改MySQL是需要有mysql里的root权限的, 所以一般用户无法更改密码,除非请求管理员。
方法1 ​:用SET PASSWORD命令
1、打开终端win+r输入cmd回车即可打开;
2、通过mysql -u用户名 -p指定root用户登录MySQL,输入后回车会提示输入密码。
3、修改MySQL的root用户密码,格式:mysql& set password for 用户名@localhost = password('新密码'); 例子:mysql& set password for
= password('shapolang'); 上面例子将用户root的密码更改为shapolang ;
重新登录,输入新密码shapolang就ok了;
方法2 :用mysqladmin
1、打开终端win+r输入cmd回车即可打开;
2、修改MySQL的root用户密码格式:mysqladmin -u用户名 -p旧密码 password 新密码
&&&&& 例子:mysqladmin -uroot -pshapolang password 123456
上面例子将用户root原来的密码shapolang改为新密码123456
重新登录,输入新密码123456就ok了;
方法3 :用UPDATE直接编辑user表
1、首先登录MySQL。
2、连接权限数据库: 。
3、改密码:update user set password=password("shapolang") where user="root";(别忘了最后加分号) 。
4、刷新权限(必须步骤):
重新登录,输入新密码shapolang就ok了;
方法4 :忘记root密码
1、关闭正在运行的MySQL服务。
2、打开DOS窗口,转到mysql\bin目录。
3、输入mysqld --skip-grant-tables 回车。 --skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
4、再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),输入mysql回车,如果成功,将出现MySQL提示符 &。
6、连接权限数据库: 。
7、改密码:update user set password=password("root") where user="root";(别忘了最后加分号) 。
8、刷新权限(必须步骤): 
9、退出& quit。
重启mysql服务,使用用户名root和刚才设置的新密码root登录就ok了;
注意事项:
mysql相关命令如果无法执行,可以将命令所在目录加入环境变量中,或者进到命令所在目录再执行。
大家还可以参考以下文章进行学习:
以上就是本文的全部内容,希望对大家的学习有所帮助。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具豆丁微信公众号
君,已阅读到文档的结尾了呢~~
如何修改mysql中root用户的密码
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
如何修改mysql中root用户的密码
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='http://www.docin.com/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口Linux下修改Mysql的用(root的密码及修改root登录权限 - luobo123 - 博客园
随笔 - 3, 文章 - 0, 评论 - 1, 引用 - 0
修改的用户都以root为列。
一、知道原来的myql数据库的root密码;
①:&在终端命令行输入&mysqladmin -u root -p password "新密码" 回车&,Enter password: 【输入原来的旧密码】②: 登录mysql系统修改,&mysql -uroot -p&回车 Enter password: 【输入原来的密码】
mysql&&update user set password=password("新密码") where user='root';&&&&&&&&【密码注意大小写】
mysql&&&&&&&&
然后使用刚才输入的新密码即可登录。二、不知道原来的myql的root的密码;首先,你必须要有操作系统的root权限了。要是连系统的root权限都没有的话,先考虑root系统再走下面的步骤。 类似于安全模式登录系统。
需要先停止mysql服务,这里分两种情况,一种可以用service mysqld stop,
另外一种是/etc/init.d/mysqld stop
当提示mysql已停止后进行下一步操作&& Shutting down MySQL. SUCCESS!
在终端命令行输入
mysqld_safe --skip-grant-tables &&&&&&&&& 【登录mysql系统】
输入mysql登录mysql系统
mysql&&UPDATE&user&SET&password=password("新密码") WHERE&user='root';&&&&& 【密码注意大小写】
重新启动mysql服务
这样新的root密码就设置成功了。
三、修改root登录权限
当你修改好root密码后,很有可能出现这种情况
ERROR ): Access denied for user 'root'@'localhost' (using password:&YES)
这是因为root登录权限不足,具体修改方法如下
需要先停止mysql服务,这里分两种情况,一种可以用service mysqld stop,
另外一种是/etc/init.d/mysqld stop
当提示mysql已停止后进行下一步操作&& Shutting down MySQL. SUCCESS!
在终端命令行输入
mysqld_safe --skip-grant-tables &&&&&&&&& 【登录mysql系统】
输入mysql登录mysql系统
mysql&update user set host = '%' where user = 'root';
mysql&select host,
然后重新启动mysql服务就可以了。}

我要回帖

更多关于 mysql5.7修改root密码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信