简体   繁体   中英

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

My client asked me to move his Wordpress site from a shared server to 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.

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 .

Then I created a new database 'WP_DB', and a new MySQL user 'wp_db_user' and granted all access to 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

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.

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:

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 Stackoverflow questions.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM