mysql - MySQL 上的用户 'user' @'localhost' 的访问被拒绝

标签 mysql database mysql-error-1045

我正在尝试将我连接到数据库 MySQL 服务器,但控制台显示错误 1045 (28000): 用户 'root'@'localhost' 的访问被拒绝(使用密码:YES)我不知道为什么。请帮我。在我的文件 my.cnf 中,我有这样的内容,

[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# To allow mysqld to connect to a MySQL Cluster management daemon, uncomment
# these lines and adjust the connectstring as needed.
#ndbcluster
#ndb-connectstring="nodeid=4;host=localhost:3306"

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[ndbd]
# If you are running a MySQL Cluster storage daemon (ndbd) on this machine,
# adjust its connection to the management daemon here.
# Note: ndbd init script requires this to include nodeid!
connect-string="nodeid=2;host=localhost:3306"

[ndb_mgm]
# connection string for MySQL Cluster management tool
connect-string="host=localhost:3306"

[client]
socket=/tmp/mysql.sock

enter image description here

谢谢。

最佳答案

如果您真的不记得密码了,您可以将 skip_grant_tables 添加到 my.cnf[mysqld] 部分,重新启动服务器,它会让你无需密码即可进入,然后你可以通过更新mysql.user表来更改密码,然后重新启动mysql并删除skip_grant_tables选项。

关于mysql - MySQL 上的用户 'user' @'localhost' 的访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11819047/

相关文章:

php - 为什么这条SQL处理了两次?

sql - 将数据从 Azure 数据库保存到 Windows 8 应用程序并从中读取数据

php - 如何使用 Ubuntu 在本地浏览器中运行 PHP

django:mysql:error(1045, "Access denied for user ' root' @'localhost' (使用密码: NO)")

mysql - 更改 root 密码并访问 localhost/phpmyadmin 时出错

mysql - 如何访问我新设置的 MySQL 数据库(获取 "Domain is currently unable to handle this request.")

PHP根据行值类别ID选择下拉列表

mysql - SQL 下限?

android - 是否可以从服务访问数据库?

mysql - MySQL 的数据库替代品可用于数百万个表