Centos - Linux terminal can connect to mysql database, but cannot connect to mysql through php program

WBOY
Release: 2016-10-10 11:56:17
Original
1146 people have browsed it

I can connect to the data through the xshell terminal:
But when I try to connect to the database online through a php (www.discountfollow.com/a.php) test file under the official domain name, the prompt:
the database is error: Access denied for user 'root'@'www.discountfollow.com' (using password: YES)
What is the reason for this problem? Thanks. . .

Reply content:

I can connect to the data through the xshell terminal:
But when I try to connect to the database online through a php (www.discountfollow.com/a.php) test file under the official domain name, the prompt:
the database is error: Access denied for user 'root'@'www.discountfollow.com' (using password: YES)
What is the reason for this problem? Thanks. . .

I once encountered a pitfall that database users can only monitor on 127.0.0.1, but not on localhost
Create a new database,

<code>CREATE DATABASE testdb;
</code>
Copy after login

You create a new database ordinary user,

<code>CREATE USER 'dba'@'127.0.0.1' IDENTIFIED BY '123456';
</code>
Copy after login

Authorization,

<code>Grant select, insert, update, delete on testdb.* to dba@'127.0.0.1' ;
</code>
Copy after login

Then use dbauser to connect testdbdatabase on 127.0.0.1

If the connection cannot be made, what is the error message? Debug based on error information, such as wrong address or wrong password. Port error etc.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!