使用 mysql 5.5.8 命令行设置密码的正确语法
我刚刚下载并安装了 WAMPserver 2.1,我想为 MySQL 5.5.8 数据库设置密码。我正在 lynda.com 上做一个教程,导师 (Kevin Skoglund) 指示输入:
mysql> use mysql
Database changed
mysql> UPDATE user
-> SET Password = PASSWORD('paSSword')
-> WHERE user = 'root';
当我按 Enter 键时,我收到有关 WHERE 语句的错误:
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 'WHERE' user='root'; at line 2
有谁知道 WHERE 语句的正确语法吗?他的课程是在 2007 年完成的,所以我猜语法已经改变了,因为它在视频中对他有用。为他返回了这一行:
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
谢谢
I've just downloaded and installed WAMPserver 2.1 and I want to set a password for the MySQL 5.5.8 database. I'm doing a tutorial at lynda.com and the tutor (Kevin Skoglund) instructions to type:
mysql> use mysql
Database changed
mysql> UPDATE user
-> SET Password = PASSWORD('paSSword')
-> WHERE user = 'root';
When I hit enter, I get this error about the WHERE statement:
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 'WHERE' user='root'; at line 2
Does anyone know the correct syntax for the WHERE statement? His lessons were done in 2007, so I guess the syntax has changed because it worked for him in the video. This line was returned for him:
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这适用于我的测试服务器:
您正在尝试设置密码而不是密码(小写)
Shai。
This works on my test server:
You are trying to set Password instead of password (lowercased)
Shai.
我在使用 lynda.com 教程时遇到了同样的问题。解决办法是:
I was having the same problem with the same lynda.com tutorial. The solution is:
以 root 身份登录 mysql,然后
进行真实场景
Login to mysql as root, then
For a real scenario
我遇到了完全相同的问题,问题解决如下:
注意:问题是我将 <>(尖括号)而不是 ()(圆括号)放入程序中,我知道这听起来很愚蠢,但这就是发生的事情。因为 () 和 <>看起来在命令行上看起来是一样的,我把它们搞乱了。
I was having exactly the same problem, the problem was solved as follows:
NOTE: The problem was that I put <>(angle brackets) instead of () (round brackets) into the program, I know it sounds really dumb, but this is what happened. Because () and <> appear to look the same on command line, I messes them up.
这段代码:
将编译(因为需要一个更好的词),但它是非常不安全的代码:
MySQL 手册对此是这么说的:
如果您坚持将密码存储在数据库中,则应始终对它们加盐并使用安全哈希。
MD5 和 SHA1 不再安全。 2005 年(!)该主题的领先专家 Bruce Scheier 表示:
“我们所有人都应该放弃 SHA-1。”
我建议使用哈希长度为 512 位的 SHA2。
这确保用户只有在知道旧密码的情况下才能更改密码。
盐需要与密码存储在同一行,但不需要保密。
只需确保将其作为密码前缀即可。
测试密码的工作原理如下:
This code:
Will compile (for want of a better word), but is very insecure code:
Here's what the MySQL manual says about it:
If you insist on storing passwords in your database, you should always salt them and use a secure hash.
MD5 and SHA1 are no longer secure. In 2005 (!) Bruce Scheier, a leading expert on this topic said:
"It's time for us all to migrate away from SHA-1."
I suggest using SHA2 with a 512 bits hash length.
This ensures that the user can only change the password when he knows the old password.
The salt needs to be stored in the same row as the password, but does not need to be secret.
Just make sure you prefix it to the password.
Testing the password works like: