首页 / MYSQL / mysql修改用户密码
mysql修改用户密码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql修改用户密码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2995字,纯文字阅读大概需要5分钟。
内容图文
1)命令行的模式
# mysqladmin -u root -p‘redhat12345‘ password ‘zabbix12345‘-S /data/3306/mysql.sock 将密码redhat12345修改为zabbix12345
2)SQL语句修改法
mysql> update mysql.user set password=‘12345‘ where user=‘root‘ and host=‘localhost‘; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select user,host,password from mysql.user; +------+------------+-------------------------------------------+ | user | host | password | +------+------------+-------------------------------------------+ | root | localhost | 12345 | | root | C67-X64-A8 | | | root | 127.0.0.1 | | | root | ::1 | | | | localhost | | | | C67-X64-A8 | | | wan | % | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | | wan | 10.10.10.% | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | | rep | 10.10.10.% | *2698A63E7F5138951B60F853417ADB4CE2A02D87 | +------+------------+-------------------------------------------+ 9 rows in set (0.00 sec) 说明:我们发现上面显示的结果中,password居然是明文显示,很明显,不可能登陆到数据库 正确的做法: 结合password()函数: mysql> update mysql.user set password=password(redhat12345) where user=‘root‘ and host=‘localhost‘; ERROR 1054 (42S22): Unknown column ‘redhat12345‘ in ‘field list‘ 错误原因,字符串应该用引号引起来(可以用单引号或者双引号) mysql> update mysql.user set password=password(‘redhat12345‘) where user=‘root‘ and host=‘localhost‘; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) 登陆进行测试: [root@mysql-master mysqlback]# mysql -uroot -predhat12345 -S /data/3306/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 27 Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql>
3)利用set命令来解决(不适合--skip-grant-tables方式修改密码)
mysql> set password=password("redhat12345"); Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
注意:
a) 修改密码的时候,必须指定where条件
b) 使用password()函数来加密更改密码
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1861052
mysql修改用户密码
标签:mysql 修改密码
本文系统来源:http://molewan.blog.51cto.com/287340/1861052
内容总结
以上是互联网集市为您收集整理的mysql修改用户密码全部内容,希望文章能够帮你解决mysql修改用户密码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。