Connect Cpanel MySQL issue (Not local host)

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
Phillip911
 
 
Posts: 40
Joined: Fri Jan 21, 2022 12:44 pm

Connect Cpanel MySQL issue (Not local host)

Post by Phillip911 »

Hi, i recently using forms and login tools to connect with MySQL, but i unable to connect it to my server. In the Cpanel i have created a database and mysql account, maybe i fill the wrong database name, server or username.

Did anyone can teach me what and how to fill it ?

Really appreciate
Professional Web Design and Development Service - Odeysoft
https://odeysoft.com
User avatar
Pablo
 
Posts: 23404
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Connect Cpanel MySQL issue (Not local host)

Post by Pablo »

Are you sure the settings are correct?
What is the error?
User avatar
BaconFries
 
 
Posts: 5933
Joined: Thu Aug 16, 2007 7:32 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by BaconFries »

i have created a database and mysql account, maybe i fill the wrong database name, server or username.
As each host is different only yours will be able to confirm that the settings and the username and password are correct so please contact them to confirm these are what should be used.
Phillip911
 
 
Posts: 40
Joined: Fri Jan 21, 2022 12:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Phillip911 »

It said
Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'
Here are the image provided

Image --- Database that i fill
Image --- MyPhp main page
Image --- Username
Image --- MySQL table

The password is 100% correct as i have ask my hosing provider
Correct me if i fill wrong. Thanks and really appreciate
Last edited by Phillip911 on Tue Feb 22, 2022 3:28 pm, edited 1 time in total.
Professional Web Design and Development Service - Odeysoft
https://odeysoft.com
User avatar
Pablo
 
Posts: 23404
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Connect Cpanel MySQL issue (Not local host)

Post by Pablo »

It looks ok as far as I can tell.
What is the error?
Phillip911
 
 
Posts: 40
Joined: Fri Jan 21, 2022 12:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Phillip911 »

When i uploaded and try signup an account, it said

Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'
Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'

Any advice ?
Professional Web Design and Development Service - Odeysoft
https://odeysoft.com
User avatar
Pablo
 
Posts: 23404
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Connect Cpanel MySQL issue (Not local host)

Post by Pablo »

This can only be a configuration issue.
You will need to contact your web host about this
User avatar
quikflixx
 
 
Posts: 24
Joined: Tue Nov 23, 2021 12:35 pm
Location: USA
Contact:

Re: Connect Cpanel MySQL issue (Not local host)

Post by quikflixx »

Phillip911 wrote: Tue Feb 22, 2022 3:29 pm When i uploaded and try signup an account, it said

Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'
Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'

Any advice ?
Try using the address instead of localhost...
127.0.0.1:3306
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Adrian »

Hello Phillip,

I don't know, but if I'm right, the error that you have say "Failed to select database" ??

if you want to connect to a database, 4 parameters are required:

1) DB Host -> in most cases "localhost". If your application is not placed on the same server where your application is hosted, you should enter here the IP address of your MYSQL Server. (Ex. 123.45.55.33)

2) DB name -> the name of the database

3) DB user -> the user that is authorized to use the database

4) DB password -> clear:-)

One more think: if the IP address of the server where your application is located and the IP Address of your MYSQL server is not the same, you MUST advise your MYSQL server to accept connections from other IP addresses. You can allow ALL IP addresses to connect to you MYSQL server or just a few.
For security reason I will suggest to accept connections just from the required IP address.

Regards, Adrian
Best Regards, Adrian

Rogarema.net
User avatar
quikflixx
 
 
Posts: 24
Joined: Tue Nov 23, 2021 12:35 pm
Location: USA
Contact:

Re: Connect Cpanel MySQL issue (Not local host)

Post by quikflixx »

Adrian wrote: Wed Feb 23, 2022 8:46 am Hello Phillip,

I don't know, but if I'm right, the error that you have say "Failed to select database" ??

if you want to connect to a database, 4 parameters are required:

1) DB Host -> in most cases "localhost". If your application is not placed on the same server where your application is hosted, you should enter here the IP address of your MYSQL Server. (Ex. 123.45.55.33)

2) DB name -> the name of the database

3) DB user -> the user that is authorized to use the database

4) DB password -> clear:-)

One more think: if the IP address of the server where your application is located and the IP Address of your MYSQL server is not the same, you MUST advise your MYSQL server to accept connections from other IP addresses. You can allow ALL IP addresses to connect to you MYSQL server or just a few.
For security reason I will suggest to accept connections just from the required IP address.

Regards, Adrian
Thanks Adrian for the more detailed suggestions from what I gave. I was on my way out the door and didn't have time.
Jim
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Adrian »

Hello quikflixx,

sorry. reply to the wrong user :-(

Regards, Adrian
Best Regards, Adrian

Rogarema.net
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Adrian »

Hello Phillip,

I don't know, but if I'm right, the error that you have say "Failed to select database" ??

if you want to connect to a database, 4 parameters are required:

1) DB Host -> in most cases "localhost". If your application is not placed on the same server where your application is hosted, you should enter here the IP address of your MYSQL Server. (Ex. 123.45.55.33)

2) DB name -> the name of the database

3) DB user -> the user that is authorized to use the database

4) DB password -> clear:-)

One more think: if the IP address of the server where your application is located and the IP Address of your MYSQL server is not the same, you MUST advise your MYSQL server to accept connections from other IP addresses. You can allow ALL IP addresses to connect to you MYSQL server or just a few.
For security reason I will suggest to accept connections just from the required IP address.

Regards, Adrian
Best Regards, Adrian

Rogarema.net
Phillip911
 
 
Posts: 40
Joined: Fri Jan 21, 2022 12:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Phillip911 »

quikflixx wrote: Wed Feb 23, 2022 7:28 am
Phillip911 wrote: Tue Feb 22, 2022 3:29 pm When i uploaded and try signup an account, it said

Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'
Failed to select database
Access denied for user 'phillip_login-test'@'localhost' to database 'phillip_login-test'

Any advice ?
Try using the address instead of localhost...
127.0.0.1:3306
I have try, but still can't
Professional Web Design and Development Service - Odeysoft
https://odeysoft.com
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Adrian »

Hello Phillip,

can you connect to your MYSQL Server in Phpmyadmin?
Every host has his own access to the mysql server and this is phpmyadmin.
With this error message, I think this is the best way to beginn finding the error.
Best Regards, Adrian

Rogarema.net
Phillip911
 
 
Posts: 40
Joined: Fri Jan 21, 2022 12:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Phillip911 »

Adrian wrote: Thu Feb 24, 2022 7:58 am Hello Phillip,

can you connect to your MYSQL Server in Phpmyadmin?
Every host has his own access to the mysql server and this is phpmyadmin.
With this error message, I think this is the best way to beginn finding the error.
Yes, i able to connect MySQL with my Php admin. When i create a database at MySQL, Php my admin will update. Current error is still "Fail to connect database" :( :(
Professional Web Design and Development Service - Odeysoft
https://odeysoft.com
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Adrian »

Hello Phillip,

----Fail to connect database mean that something is wrong.

If Phpmyadmin works and your application don't work AND all the settings are correct, than please take into consideration this point:
---------------------
One more think: if the IP address of the server where your application is located and the IP Address of your MYSQL server is not the same, you MUST advise your MYSQL server to accept connections from other IP addresses. You can allow ALL IP addresses to connect to you MYSQL server or just a few.
For security reason I will suggest to accept connections just from the required IP address.
--------------------
Best Regards, Adrian

Rogarema.net
Phillip911
 
 
Posts: 40
Joined: Fri Jan 21, 2022 12:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Phillip911 »

Adrian wrote: Thu Feb 24, 2022 12:42 pm Hello Phillip,

----Fail to connect database mean that something is wrong.

If Phpmyadmin works and your application don't work AND all the settings are correct, than please take into consideration this point:
---------------------
One more think: if the IP address of the server where your application is located and the IP Address of your MYSQL server is not the same, you MUST advise your MYSQL server to accept connections from other IP addresses. You can allow ALL IP addresses to connect to you MYSQL server or just a few.
For security reason I will suggest to accept connections just from the required IP address.
--------------------
I have ask my host provider about the MySQL IP, they said the IP of the MySQL is same as the file manager. So i think it not the issue of IP, i still try and error
Professional Web Design and Development Service - Odeysoft
https://odeysoft.com
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: Connect Cpanel MySQL issue (Not local host)

Post by Adrian »

Hello Phillip,

I have another Idea :-)

I put you here a php script, fill it correctly and upload him to your server.
After that, call the php file in the browser (your_Domain/path/file.php)and look what's happen.
If connection is established, you application has a problem.
If your connection fail, the database connection parameters are false.

<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'db_name';
$dbuser = 'db_user';
$dbpass = 'db_passwd';
$dbhost = 'localhost or IP';
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
mysqli_select_db($link, $dbname) or die("Could not open the db '$dbname'");
$test_query = "SHOW TABLES FROM $dbname";
$result = mysqli_query($link, $test_query);
$tblCnt = 0;
while($tbl = mysqli_fetch_array($result)) {
$tblCnt++;
#echo $tbl[0]."<br />\n";
}
if (!$tblCnt) {
echo "There are no tables<br />\n";
} else {
echo "There are $tblCnt tables<br />\n";
}
?>
Best Regards, Adrian

Rogarema.net
Post Reply