-1

为什么我们需要 --skip-grant-tables 来删除Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) linux/unix 或 windows 的每个地方都有相同的错误。谁能解释一下。--skip-grant-tables 究竟做了什么?这是我的代码

import MySQLdb
db=MySQLdb.connect(host="localhost",
                   user="root",
                   passwd="********",
                   db="test")
4

3 回答 3

2

Straight from the MySQL Docs:

This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases. You can cause a running server to start using the grant tables again by executing mysqladmin flush-privileges or mysqladmin reload command from a system shell, or by issuing a MySQL FLUSH PRIVILEGES statement after connecting to the server. This option also suppresses loading of user-defined functions (UDFs).

Basically, this removes the Access Denied error by not checking the password, which is useful in a few cases (basically when instructed by the docs), such as when you are resetting your root password. However, this is not a solution to an Access Denied error. That would be like taking the lock off your door after discovering your house key doesn't work!

于 2014-04-03T21:33:02.933 回答
0

我想现在我明白了,这里的错误是Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 所以我只是将我的代码更改为:

import MySQLdb
db=MySQLdb.connect("localhost","root",'',"test")

或者

import MySQLdb
db=MySQLdb.connect(host="localhost",
                   user="root",
                   passwd='',
                   db="test")

在这里我将NULL密码设置为错误是Access denied for user using password yes

现在,如果有人对此有任何疑问,请讨论...谢谢

于 2014-04-05T21:26:08.173 回答
0

您的 mysql 密码和您在应用程序中使用的密码之间必须存在冲突。您不应该使用--skip-grant-tables选项,因为它会在不使用特权系统的情况下启动您的服务器。这对你来说一定很危险。如果您将使用它,任何人都可以访问您的帐户。

于 2015-07-18T03:19:08.410 回答