简体   繁体   English

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

[英]Access Denied for user 'linuxuser'@'localhost' (using password: no)

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. AWS EC2实例是带有MySQL 5.5.5和PHP 5.5.9的Ubuntu 14.04 LTS。 Old server has PHP 5.4.30 and MySQL 5.5.42. 旧服务器具有PHP 5.4.30和MySQL 5.5.42。 There is no PHPMyAdmin and CPanel installed on AWS instance. AWS实例上没有安装PHPMyAdmin和CPanel。 So I have to do everything using commands. 所以我必须使用命令来做所有事情。

In AWS instance, I have sudo access as 'ubuntu' user. 在AWS实例中,我具有“ ubuntu”用户的sudo访问权限。 I created a new Linux user 'wpsite' and created home directory for it. 我创建了一个新的Linux用户“ wpsite”并为其创建了主目录。 I managed to transfer all files & directories from old server to /home/wpsite/public_html . 我设法将所有文件和目录从旧服务器传输到/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). 然后,我使用wp_db_user帐户(也尝试了root用户)从sql dump中恢复了旧的WP数据库。 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. 接下来,我使用适当的服务器名称和别名以及目录路径在Apache中创建了虚拟主机配置,并将域的A-Record更改为AWS实例。 Upto this point, everything went smooth. 至此,一切进展顺利。 There were no error. 没有错误。

When I visit the website, the wordpress site is displayed, but problem is that certain contents are missing including title of site. 当我访问该网站时,会显示wordpress网站,但问题是缺少某些内容,包括网站标题。 I had a look at error log file and this error is listed in multiple lines: 我查看了错误日志文件,此错误在多行中列出:

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. 请注意,错误消息中提到的用户不是MySQL用户。 It is a Linux user. 它是Linux用户。 I cannot pinpoint whether it is problem with Wordpress or PHP version, or MySQL. 我无法确定是Wordpress还是PHP版本还是MySQL问题。 I am not pro in Linux either. 我也不是Linux专业人士。 I have done everything reading from blogs and other Stackoverflow questions. 我已经完成了阅读博客和其他Stackoverflow问题的所有工作。

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管理部分,它使用相同的数据库而没有任何错误。

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). 无论front-page.php为执行查询做什么,实际上并没有向MySQL提供密码(错误消息中的“使用密码:否”位)。 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. 如果您可以弄清楚该脚本正在与数据库进行通讯,那么您也必须对其进行修改以提供密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用户'XXX'@'localhost'的访问被拒绝(使用密码:否) - Access denied for user 'XXX'@'localhost' (using password: NO) 用户“ @'localhost”的访问被拒绝(使用密码:NO) - Access denied for user ''@'localhost' (using password: NO) 用户'root'@'localhost'的访问被拒绝(使用密码:NO) - Access denied for user 'root'@'localhost' (using password: NO) 用户'consult'@'localhost'的访问被拒绝(使用密码:否) - Access denied for user 'consult'@'localhost' (using password: NO) 用户'@'localhost'的Webmatrix访问被拒绝(使用密码:否) - Webmatrix Access denied for user ''@'localhost' (using password: NO) 用户 'apache'@'localhost' 访问被拒绝(使用密码:NO) - Access denied for user 'apache'@'localhost' (using password: NO) 用户'root'@'localhost'访问被拒绝(使用密码:NO); - Access denied for user 'root'@'localhost' (using password: NO); 用户“ @'localhost”的访问被拒绝(使用密码:NO)phpmyadmin - Access denied for user ''@'localhost' (using password: NO) phpmyadmin 用户'name'@'localhost'的访问被拒绝(使用密码:NO) - Access denied for user 'name'@'localhost' (using password: NO) 用户 'user'@'localhost' 的访问被拒绝(使用密码:YES)错误 - Access denied for user 'user'@'localhost' (using password: YES) error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM