PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 2, 2022

[FIXED] Unable to connect mysql and php in Lamp on online server

 March 02, 2022     lamp, mysql, php, ubuntu     No comments   

Issue

I am using XAMPP on my computer. My website is running fine on it. Now I uploaded my files to server using scp. Now I tried to change my connection parameter. I change it

<?php 
        $host ="104.236.227.173";
        $username = "****";
        $password = "******";
        $database = "****";

        @session_start();

 ?>

The host is the server on which my website is running.

Mysite

But online I am unable to connect to database. I installed Lamp online. I have changed settings in my.conf. But it does not work. I have used the following command too

GRANT ALL ON `database`.* TO username@'%' IDENTIFIED BY 'password';

Please help me to solve this.


Solution

As shared using 'localhost' instead the IP address should do the trick. You're accessing the mysql on the same server as the php script is running. Unless the mysql server is configured to be available via IP address, 'localhost' is default behaviour. Glad it helped!



Answered By - David Jirman
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing