访问被拒绝用户'linuxuser'@'localhost'(使用密码:否)

时间:2022-05-24 01:58:00

My client asked me to move his Wordpress site from a shared server to AWS.

我的客户要求我将他的Wordpress站点从共享服务器移动到AWS。

The AWS EC2 instance is Ubuntu 14.04 LTS with PHP 5.5.9 with MySQL 5.5.38. Old server has PHP 5.4.30 and MySQL 5.5.42. There is no PHPMyAdmin and CPanel installed on AWS instance. So I have to do everything using commands.

AWS EC2实例是Ubuntu 14.04 LTS,PHP 5.5.9,MySQL 5.5.38。旧服务器有PHP 5.4.30和MySQL 5.5.42。 AWS实例上没有安装PHPMyAdmin和CPanel。所以我必须使用命令做所有事情。

In AWS instance, I have sudo access as 'ubuntu' user. I created a new Linux user 'wpsite' and created home directory for it. I managed to transfer all files & directories from old server to /home/wpsite/public_html.

在AWS实例中,我将sudo访问权限作为“ubuntu”用户。我创建了一个新的Linux用户'wpsite'并为其创建了主目录。我设法将所有文件和目录从旧服务器传输到/ home / wpsite / public_html。

Then I created a new database 'WP_DB', and a new MySQL user 'wp_db_user' and granted all access to WP_DB.

然后我创建了一个新的数据库'WP_DB'和一个新的MySQL用户'wp_db_user'并授予了对WP_DB的所有访问权限。

CREATE USER wp_db_user@localhost IDENTIFIED BY 'thepwd';
GRANT ALL PRIVILEGES ON WP_DB.* TO wp_db_user@localhost IDENTIFIED BY 'thepwd';
FLUSH PRIVILEGES;

Now, I changed wp-config.php file

现在,我更改了wp-config.php文件

define('DB_NAME', 'WP_DB');
define('DB_USER', 'wp_db_user');
define('DB_PASSWORD', 'thepwd');
define('DB_HOST', 'localhost');

Then I restored old WP database from sql dump, using wp_db_user account (tried with root user as well). Next, I created a v-host configuration in Apache with proper server name & alias, and directory path, and changed A-Record of the domain to AWS instance. Upto this point, everything went smooth. There were no error.

然后我使用wp_db_user帐户从sql dump恢复旧的WP数据库(也尝试使用root用户)。接下来,我在Apache中创建了一个v-host配置,其中包含正确的服务器名称和别名以及目录路径,并将域的A-Record更改为AWS实例。到目前为止,一切顺利。没有错误。

When I visit the website, the wordpress site is displayed, but problem is that certain contents are missing including title of site. I had a look at error log file and this error is listed in multiple lines:

当我访问网站时,会显示wordpress网站,但问题是某些内容缺失,包括网站标题。我看了一下错误日志文件,这个错误列在多行中:

Access Denied for user 'ubuntu'@'localhost' (using password: no) in /home/wpsite/public_html/wp-content/themes/enterprise-pro/front-page.php on line 5

and the said line contains following code

并且所述行包含以下代码

$sel_home = mysql_query("select * from admin_home_page");

Point to note that the user mentioned in error message is not a MySQL user. It is a Linux user. I cannot pinpoint whether it is problem with Wordpress or PHP version, or MySQL. I am not pro in Linux either. I have done everything reading from blogs and other * questions.

请注意,错误消息中提到的用户不是MySQL用户。它是Linux用户。我无法确定它是否是Wordpress或PHP版本或MySQL的问题。我也不是Linux的专业人士。我已经完成了从博客和其他*问题中读取的所有内容。

The website is working fine in old server. Could someone please tell me what I am doing wrong, and what could be done to solve this problem?

该网站在旧服务器上运行良好。有人可以告诉我我做错了什么,可以做些什么来解决这个问题?

Thanks in advance.

提前致谢。

EDIT: I can log in to WP admin section, which uses same database without any error.

编辑:我可以登录到WP管理部分,它使用相同的数据库,没有任何错误。

1 个解决方案

#1


0  

Whatever front-page.php is doing to execute the query isn't actually providing the password to MySQL (per the "using password: no" bit in the error message). If you can figure out what that script is doing to talk to the database, you'll have to modify it to provide the password too.

无论front-page.php执行查询是什么,实际上并没有向MySQL提供密码(根据错误消息中的“using password:no”位)。如果你能弄清楚那个脚本正在做什么来与数据库通信,你就必须修改它以提供密码。

#1


0  

Whatever front-page.php is doing to execute the query isn't actually providing the password to MySQL (per the "using password: no" bit in the error message). If you can figure out what that script is doing to talk to the database, you'll have to modify it to provide the password too.

无论front-page.php执行查询是什么,实际上并没有向MySQL提供密码(根据错误消息中的“using password:no”位)。如果你能弄清楚那个脚本正在做什么来与数据库通信,你就必须修改它以提供密码。