CakePHP数据库:SQLSTATE 28000 - 错误1045访问被拒绝用户'kcal'@'localhost'

时间:2022-02-02 19:19:36

I'm moving my websites from a little VPS to a big dedicated server. But this is one strange problem.

我正在将我的网站从一个小VPS移动到一个大的专用服务器。但这是一个奇怪的问题。

I keep getting this error:

我一直收到这个错误:

Missing Database Connection

Error: SQLSTATE[28000] [1045] Access denied for user 'kcal'@'localhost' (using password: YES) requires a database connection

Error: Confirm you have created the file : app/Config/database.php.

Notice: If you want to customize this error message, create app/View/Errors/missing_connection.ctp.

Yes: the file has been created, the user has been made, the password is correct. (I even changed it to something simple. Twice)

是:文件已创建,用户已创建,密码正确。 (我甚至把它变成了简单的东西。两次)

Yet I still get this error.

但我仍然得到这个错误。

I read I need the pdo_mysql extension, but that's installed by default. I have it, it's installed and enabled!

我读过我需要pdo_mysql扩展名,但默认安装。我有它,它已安装并启用!

All my other applications work fine. This is the only CakePHP one, though.

我所有的其他应用程序工作正常不过,这是唯一的CakePHP。

3 个解决方案

#1


3  

An access denied error indicates exactly that - Cake is able to talk to MySQL, and it's saying access is denied with the user@host indicated. Proabbly because the user doesn't have access to the checkpoint_live database.

拒绝访问错误表明 - Cake可以与MySQL通信,并且表示访问被拒绝,并指示了user @ host。可能是因为用户无权访问checkpoint_live数据库。

Since you just moved to a new server, you probably need to grant privileges on the MySQL table for that particular user@host. Creating the same user with the same password isn't enough. Try this:

由于您刚刚迁移到新服务器,因此您可能需要为该特定用户@主机授予MySQL表的权限。使用相同的密码创建相同的用户是不够的。尝试这个:

GRANT ALL PRIVILEGES ON checkpoint_live.* TO 'kcal'@'localhost';
FLUSH PRIVILEGES;

#2


0  

Check the username password you typed in app/Config/database.php. It should looks like:

检查您在app / Config / database.php中输入的用户名密码。它应该看起来像:

class DATABASE_CONFIG {

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => '127.0.0.1',
    'login' => 'kcal',
    'password' => '---ORIGINIAL PASSWORD HERE---',
    'database' => 'checkpoint_live',
    'prefix' => '',
    'encoding' => 'utf8',
);
}

#3


0  

Check to see if you have any extra spaces in your login or password. I just had this same issue and it was caused by an extra space at the beginning of the password.

检查您的登录名或密码中是否有任何多余的空格。我只是遇到了同样的问题,这是由密码开头的额外空间引起的。

#1


3  

An access denied error indicates exactly that - Cake is able to talk to MySQL, and it's saying access is denied with the user@host indicated. Proabbly because the user doesn't have access to the checkpoint_live database.

拒绝访问错误表明 - Cake可以与MySQL通信,并且表示访问被拒绝,并指示了user @ host。可能是因为用户无权访问checkpoint_live数据库。

Since you just moved to a new server, you probably need to grant privileges on the MySQL table for that particular user@host. Creating the same user with the same password isn't enough. Try this:

由于您刚刚迁移到新服务器,因此您可能需要为该特定用户@主机授予MySQL表的权限。使用相同的密码创建相同的用户是不够的。尝试这个:

GRANT ALL PRIVILEGES ON checkpoint_live.* TO 'kcal'@'localhost';
FLUSH PRIVILEGES;

#2


0  

Check the username password you typed in app/Config/database.php. It should looks like:

检查您在app / Config / database.php中输入的用户名密码。它应该看起来像:

class DATABASE_CONFIG {

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => '127.0.0.1',
    'login' => 'kcal',
    'password' => '---ORIGINIAL PASSWORD HERE---',
    'database' => 'checkpoint_live',
    'prefix' => '',
    'encoding' => 'utf8',
);
}

#3


0  

Check to see if you have any extra spaces in your login or password. I just had this same issue and it was caused by an extra space at the beginning of the password.

检查您的登录名或密码中是否有任何多余的空格。我只是遇到了同样的问题,这是由密码开头的额外空间引起的。