# Cant Connect to my MySql Database

**URL:** <https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918>\
**Category:** Hosting Support\
**Created:** [June 21, 2023, 5:44am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918 "2023-06-21T05:44:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 5:44am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/1 "2023-06-21T05:44:53Z")

</div>

### Website

[http://my-test-website.infinityfreeapp.com/test.php](http://my-test-website.infinityfreeapp.com/test.php)

### Error Message

Connection failed: php\_network\_getaddresses: getaddrinfo failed: Name or service not known

### Other Information

Hi There,

I am trying to connect to my mysql database from my php script called test.php. I have tried both mysql hostname: sql110.epizy. com and sql110.infinityfree. com. The password is the one created when click the show/hide button.

I add spaces to the two hostname urls to bypass the topic posting system

\<?php $servername = "sql110.epizy.com"; $username = "epiz\_34272048"; $password = "YLGWNKxkuwCc"; // Create connection $conn = new mysqli($servername, $username, $password,"epiz\_34272048\_computer\_store "); // Check connection if ($conn-\>connect\_error) { die("Connection failed: " . $conn-\>connect\_error); } echo "Connected successfully"; $conn-\>close(); ?\>

---

<div class="post-metadata">

**Author:** ![HELPINDIA](https://forum.infinityfree.com/letter_avatar/helpindia/32/6_449c533f586939b6e5f246632a46421f.png) [@HELPINDIA](https://forum.infinityfree.com/u/HELPINDIA)\
**Post date:** [June 21, 2023, 5:54am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/2 "2023-06-21T05:54:42Z")

</div>

Stop exposing credentials here like password !  
Where is DB NAME ??  
DB connection should like host name DB NAME DB USER DB PASS like this

---

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 5:56am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/3 "2023-06-21T05:56:22Z")

</div>

> [@Devin.Lupichuk](#):
>
> epiz\_34272048\_computer\_store

epiz\_34272048\_computer\_store is the DBNAME

Didnt realize this was a public from thought there was support ticket system.

---

<div class="post-metadata">

**Author:** ![HELPINDIA](https://forum.infinityfree.com/letter_avatar/helpindia/32/6_449c533f586939b6e5f246632a46421f.png) [@HELPINDIA](https://forum.infinityfree.com/u/HELPINDIA)\
**Post date:** [June 21, 2023, 6:00am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/4 "2023-06-21T06:00:43Z")

</div>

Support ticket system is only for premium user!  
If you want to support only from ticket system then upgrade your account to premium hosting!

Or If you want solution only (no matter where is comes from) then here someone will help you!

---

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 6:08am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/5 "2023-06-21T06:08:32Z")

</div>

Great I can’t delete my post.

---

<div class="post-metadata">

**Author:** ![KangJL](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/kangjl/32/12130_2.png) [@KangJL](https://forum.infinityfree.com/u/KangJL)\
**Post date:** [June 21, 2023, 6:12am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/6 "2023-06-21T06:12:30Z")

</div>

Well, you can change your password for a start

---

<div class="post-metadata">

**Author:** ![anon42008019](https://forum.infinityfree.com/letter_avatar/anon42008019/32/6_449c533f586939b6e5f246632a46421f.png) [@anon42008019](https://forum.infinityfree.com/u/anon42008019)\
**Post date:** [June 21, 2023, 6:31am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/7 "2023-06-21T06:31:08Z")

</div>

> [@HELPINDIA](#):
>
> Support ticket system is only for premium user!  
> If you want to support only from ticket system then upgrade your account to premium hosting!

This is really unnecessary.  
Admin does not provide premium hosting on his own (what you know about premium hosting is ifastnet ruled by someone else)  
The forum exists so others can help the people who have issues + different users can look up the answers via the search feature here.

* * *
 Can you try formatting your code to be more readable? 

```

Code goes here

```

---

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 6:40am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/8 "2023-06-21T06:40:33Z")

</div>

```auto
<?php 
$servername = "sql110.epizy.com"; 
$username = "epiz_randomNumbers"; 
$password = "cpanel password"; 

// Create connection
 $conn = new mysqli($servername, $username, $password,"epiz_34272048_computer_store "); 

// Check connection 
if ($conn->connect_error) 
{ 
          die("Connection failed: " . $conn->connect_error); 
}
 
echo "Connected successfully"; $conn->close(); 
?>

```

---

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 6:49am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/9 "2023-06-21T06:49:57Z")

</div>

How I can.t find it. only the client area password one is all I can find.

---

<div class="post-metadata">

**Author:** ![KangJL](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/kangjl/32/12130_2.png) [@KangJL](https://forum.infinityfree.com/u/KangJL)\
**Post date:** [June 21, 2023, 7:01am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/10 "2023-06-21T07:01:03Z")

</div>

You can change password here

 ![image](https://forum-cdn.infinityfree.net/original/3X/1/5/155952ab5e58b17a799e245b629398c8d7d2798e.png)

---

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 7:03am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/11 "2023-06-21T07:03:48Z")

</div>

Thanks,

Must be blind

---

<div class="post-metadata">

**Author:** ![ChrisPAR](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/chrispar/32/8743_2.png) [@ChrisPAR](https://forum.infinityfree.com/u/ChrisPAR)\
**Post date:** [June 21, 2023, 9:24am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/12 "2023-06-21T09:24:19Z")

</div>

From the code you sent, it appears that you’ve put an extra space before closing the quotation marks around your database name, so that could be a reason why you are getting an error.

I am curious, why do you hardcode it in the connection instead of creating a variable like you have done with the other values?

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [June 21, 2023, 9:39am UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/13 "2023-06-21T09:39:01Z")

</div>

I took a look at the actual code that’s on your site, and there is a small but critical difference between what’s in the file and what you’ve shared here.

Because the current content of line two is this:

```php
    $servername = "sql110.infinityfree.com ";

```

At the end of the servername string is a trailing space. That may seem irrelevant, but when it comes to configuration, the value must be _exactly_ the right one, and adding a space makes it a different value.

If you remove the space, it will fix this error.

* * *

Changing just this won’t also fix your database connection. The password in the config file is no longer correct because you already change the password of your account. And the password string also contains extra spaces, which will also break it.

Finally, you may also need to add the database name to the connect function. And as with the hostname and password: please make sure that no extra spaces are included.

---

<div class="post-metadata">

**Author:** ![Devin.Lupichuk](https://forum.infinityfree.com/letter_avatar/devin.lupichuk/32/6_449c533f586939b6e5f246632a46421f.png) [@Devin.Lupichuk](https://forum.infinityfree.com/u/Devin.Lupichuk)\
**Post date:** [June 21, 2023, 8:29pm UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/14 "2023-06-21T20:29:46Z")

</div>

Well the problem is solved but the issue was that somehow the ftp server wasnt saving my changes without telling me.

I already tried removing the extra spaces and including the dnmane I also tried the other sql hostname(the one in cpanel is different then the one in main mysql account tab). None of these worked because of the above mentioned bug that the ftp server wasn’t actually saving my changes to the file.

anyways thanks for everyone responding.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [June 28, 2023, 8:30pm UTC](https://forum.infinityfree.com/t/cant-connect-to-my-mysql-database/77918/15 "2023-06-28T20:30:02Z")

</div>

Closed on June 28, 2023, 8:30pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
