解决“OperationalError: (1862, 'Your password has expired. To log in you must change it using ...”
来源:互联网 发布:网络与信息安全教程 编辑:程序博客网 时间:2024/05/29 17:42
1. 问题描述
在64位的ubuntu14.10下进行Django框架开发, 在测试mysql是否可以连通时出现以下信息:
xx@ubuntu:~/workspace/day02$ python manage.py shellPython 2.7.8 (default, Oct 20 2014, 15:05:19) [GCC 4.9.1] on linux2Type "help", "copyright", "credits" or "license" for more information.(InteractiveConsole)>>> from django.db import connection>>> cursor = connection.cursor()Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 165, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 138, in _cursor self.ensure_connection() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 133, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 133, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 122, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 472, in get_new_connection conn = Database.connect(**conn_params) File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg/MySQLdb/__init__.py", line 81, in Connect return Connection(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 187, in __init__ super(Connection, self).__init__(*args, **kwargs2)OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)")>>> cursor = connection.cursor()Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 165, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 138, in _cursor self.ensure_connection() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 133, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 133, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 122, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 472, in get_new_connection conn = Database.connect(**conn_params) File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg/MySQLdb/__init__.py", line 81, in Connect return Connection(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 187, in __init__ super(Connection, self).__init__(*args, **kwargs2)OperationalError: (1862, 'Your password has expired. To log in you must change it using a client that supports expired passwords.')>>>
由上面的"OperationalError: (1862, 'Your password has expired. To log in you must change it using a client that supports expired passwords.')"可知, mysql用户的密码过期了
但我记得在安装完mysql后设置了root用户的密码为123456, 且执行以下命令能正常进入mysql的shell:
mysql -uroot -p123456
既然能正常进入mysql的控制台, 但不能正常连接mysql, 那么我们再次设置密码, 我参考了以下链接:http://dev.mysql.com/doc/refman/5.6/en/set-password.html
发现以前那种修改密码的方法不可用, 只有SET PASSWORD = PASSWORD('123456')能有效:
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> user mysql;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user mysql' at line 1mysql> use mysql;ERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root';ERROR 1046 (3D000): No database selectedmysql> use mysql;ERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> SET PASSWORD = PASSWORD('123456');Query OK, 0 rows affected (0.10 sec)mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql>
于是再次测试能否通过连接, 结果成功连上mysql数据库, 如下:
OperationalError: (1862, 'Your password has expired. To log in you must change it using a client that supports expired passwords.')>>> cursor = connection.cursor()>>>
3. 若window下出现这种情况
若window下出现这种情况, 则到mysql的安装目录下的bin目录下, 执行 mysql -uroot -p 进入mysql shell
OK, Enjoy it!!!
0 0
- 解决“OperationalError: (1862, 'Your password has expired. To log in you must change it using ...”
- Your password has expired. To log in you must change it using a cl...
- Your password has expired.To log in you must change it using a client that supports expired password
- Mysql 5.7 错误号码1862 Your password has expired. To log in you must change it using a client...
- ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supp
- Your password has expired. To log in you must change it using a client that supports expired passwor
- Your password has expired. To log in you must change it using a client that supports expired passwo
- Your password has expired. To log in you must change it using a client that supports expired passwor
- Your password has expired. To log in you must change it using a client that supports expired passwor
- java.sql.SQLException: Your password has expired. To log in you must change it using a client that s
- MySQL5.7出现Your password has expired. To log in you must change it using a client that supports expir
- MySQL5.7出现Your password has expired. To log in you must change it using a client that supports expir
- 【MySQL】MySQL 5.7 "Your password has expired.To log in you must change it using a client that suppor"
- mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must change
- mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must chang
- mysql 5.7 To log in you must change it using a client that supports expired passwords
- ERROR: You must wait longer to change your password passwd: Authentication token manipulation error
- mysql your password has expired
- Java集合框架总结(4)——List接口的使用
- 【干货】国外程序员整理的 C++ 资源大全
- ajax异步请求,session超时处理
- java日志系统
- zopo zp520 buy elephone g3
- 解决“OperationalError: (1862, 'Your password has expired. To log in you must change it using ...”
- Maven多模块实战
- [码海拾贝 之Perl]获取日期以及日期的加减
- [PHP]php cli命令行下运行php的三种方法(带参数)
- jquery对于click事件的参数
- 自定义RadioButton&CheckBox样式的实现
- 从Google Spanner漫谈分布式存储与数据库技术
- web 会话超时,请求(http请求和ajax异步请求)处理
- gcc源代码分析gen_push_operand ()函数和emit_move_insn ()函数