DWQA QuestionsCategory: ServerPHP link to Alibaba cloud ECS remote database
shwy asked 2 months ago

PHP links to a remote server on Alibaba cloud. It uses native tests and simple code.
First:

1. MySQL related extensions have been installed
2. the MySQL server on the remote server has allowed remote access, and the local connection test has been successful through phpstrom, native premium and other tools.

But now there is a problem. When I was in mysqli_ When the first parameter of contentn() is filled in the remote address, the IP address of the final error message is actually my Internet address.
As shown in the following figure:
    183.156.*.*: This is my Internet address.
    139.224.*.*: This is the remote MySQL address I want to access
Now the puzzle is, please give me some advice!

clipboard.png
clipboard.png,Look at the following results

use mysql;
select Host,User,Password from user;

,@The latter originally refers to the IP address of the client. Check whether the user name, password and database name are correct,Alibaba cloud databases are not accessible from the Internet,To be clear, your phpstorm and Navicat use this 183.156 x. X IP connected database? If so, I don’t know how to solve it. If not, I think you should know how to solve it.,As the above partner replied to you:
The address in the error report should be your Internet IP. It represents the connection source IP, not the server IP.
As for why you can’t connect to the PHP script database, I really feel that you may be dazzled. Is there a wrong user name, password and database. Fill the data in the code into the tool and try again?
Anyway, it feels a little weird!!!,I seem to know the problem. I just read the MySQL [email protected] Xuankong alien
Embarrassed, as if Aite couldn’t help others)
clipboard.png
The passwords in the first and third lines are always set locally.
The password in the second line is the password set in my online code.
In other words, MySQL will be based on different sources, but the users are the same and the passwords are different..
In the end, I still rely on the reminder of @ Xuankong alien to check the password.. And find the problem
clipboard.png

6 Answers
Lingfengzi answered 2 months ago

Look at the following results

use mysql;
select Host,User,Password from user;
amorZhu replied 2 months ago

The author said that phpstorm and navicate can be connected. This reason may not exist.

Lingfengzi replied 2 months ago

Thanks for reminding me. I was careless.

amorZhu replied 2 months ago

You’re welcome. You’ve at least provided a solution.

shwy replied 2 months ago

Thank you for your answer. 1) I have opened all ports for testing.

shwy replied 2 months ago

This, as shown in Figure 1, is the statement of this result. On the left is my 135.224.Also remote data.. This is linked using navicate.

Lingfengzi replied 2 months ago

@Shwy password field is not empty

shwy replied 2 months ago

Of course, it’s not empty. Because the online code is accessible. Just changed the address to 127.0.0.1 The user name and password are consistent

Lingfengzi replied 2 months ago

@If shwy can, try resetting the root password. There’s no other way.

shwy replied 2 months ago

Reset.. Still the same, unable to access, egg’s sadness

Lingfengzi replied 2 months ago

@Shwy service MySQL restart or flush privileges?

shwy replied 2 months ago

That’s for sure. My server has been restarted directly.. I’m looking. Thank you

shwy replied 2 months ago

3q, I know the solution to the problem. Look at the last one I sent

keepeye answered 2 months ago

@The latter originally refers to the IP address of the client. Check whether the user name, password and database name are correct

shwy replied 2 months ago

User name and password. The name can be guaranteed to be correct. Because I copied it directly from the online code. The difference between online and offline is that the address is different

keepeye replied 2 months ago

I used Alibaba cloud to test it myself. There is no problem. Since local tools can be connected, PHP can certainly be connected

shwy replied 2 months ago

Yes, but look at my doubts. My mysqli_ Content (), the address is the IP address of my remote server. Then, the wrong IP address is indeed the IP address of our external network..

keepeye replied 2 months ago

The address in the error report should be your Internet IP. It represents the connection source IP, not the server IP

shwy replied 2 months ago

Read the error message carefully: mysqli_ Connect(): (hy000/1045): access denied for user’root’@’183.156.‘ (using password: YES)What this means is that I am putting 183.156.The server of this one. Instead of 135. And 135 is the remote server address I want to access

keepeye replied 2 months ago

Alas, if you use the client, change the password to see what the error information is

shwy replied 2 months ago

I just tried. First, I changed the online code directly, and the password became the wrong password. Then access directly through the online domain name. The error is mysqli_ Connect(): (hy000/1045): access denied for user’root’@’localhost'(using password: yes). Ps: the server address of my online configuration is 127.0.0.1 Therefore, this is localhost. So, the IP you said was the source IP. I don’t think so

hold_baby answered 2 months ago

Alibaba cloud databases are not accessible from the Internet

shwy replied 2 months ago

Why can I successfully link with data tools such as native premium? Figure 1 shows the link after it is successfully linked.Moreover, I have opened all the agreements.. But it seems that there is no way to send pictures in the commentsAllow all-1/-1 address segment access0.0.0.0/0-110 2017-05-04 15:38:14

amorZhu answered 2 months ago

To be clear, your phpstorm and Navicat use this 183.156 x. X IP connected database? If so, I don’t know how to solve it. If not, I think you should know how to solve it.

shwy replied 2 months ago

The successful link between phpstorm and Navicat is 139.224.Database for. 183.156 x. X this is the IP address of our company’s external network. There is no database.. So, my doubts are actually here..

bingodawson answered 2 months ago

As the above partner replied to you:
The address in the error report should be your Internet IP. It represents the connection source IP, not the server IP.
As for why you can’t connect to the PHP script database, I really feel that you may be dazzled. Is there a wrong user name, password and database. Fill the data in the code into the tool and try again?
Anyway, it feels a little weird!!!

shwy replied 2 months ago

Look at the last answer. I already know the question.. Sensory response

shwy answered 2 months ago

I seem to know the problem. I just read the MySQL [email protected] Xuankong alien
Embarrassed, as if Aite couldn’t help others)
clipboard.png
The passwords in the first and third lines are always set locally.
The password in the second line is the password set in my online code.
In other words, MySQL will be based on different sources, but the users are the same and the passwords are different..
In the end, I still rely on the reminder of @ Xuankong alien to check the password.. And find the problem
clipboard.png

Lingfengzi replied 2 months ago

Yes, even if the user name and password are the same, different or empty passwords correspond to different connection methods. I have experienced this pit for many times.

shwy replied 2 months ago

This is my first time to encounter this pit. Thank you for your help

shwy replied 2 months ago

What’s more, all my passwords have been changed, and I can still log in with root..

amorZhu replied 2 months ago

See