Problems connecting to MySQL from PHP -


i’ve created database called database_test & have user named john , password hello123. host host.

<?php // create connection $host = "host"; // host correct. i'm hiding general public. $user = "john"; $password = "hello123"; $database =  "database_test";  $con=mysqli_connect($host,$user,$password,$database);  // check connection if (mysqli_connect_errno()) {   echo "failed connect mysql: " . mysqli_connect_error(); } ?> 

however, i'm getting error:

failed connect mysql: access denied user 'john'@'host' (using password: yes)

i’ve set permissions user “john” shown below…

enter image description here

why getting error? have host correct, username , password correct it’s saying user not have privileges

is hostname other localhost or 127.0.0.1? if firewall issue.

to check if host remotely available, can use mmap. nmap common network utility not installed default on linux machines or mac os x machines, can installed & run command line.

just run nmap server code want use connect remote host resides so:

nmap [hostname or ip address] -p 3306 

port 3306 mysql port , output if port open be:

starting nmap 5.21 ( http://nmap.org ) @ 2014-05-16 18:56 edt nmap scan report localhost (127.0.0.1) host (0.00013s latency). port     state service 3306/tcp open  mysql  nmap done: 1 ip address (1 host up) scanned in 0.40 seconds 

but if it’s closed, be:

starting nmap 6.25 ( http://nmap.org ) @ 2014-05-16 18:57 edt nmap scan report localhost (127.0.0.1) host (0.000096s latency). port     state  service 3306/tcp closed mysql  nmap done: 1 ip address (1 host up) scanned in 0.17 seconds 

also, can check grants user john has on mysql database server running command:

show grants 'john'@'127.0.0.1'; 

or localhost instead of ip address;

show grants 'john'@'localhost'; 

while screenshot shows have granted privileges, need make sure took. within mysql setting grant , running, flush privileges;

past that, have seen mysql setups don’t consider 127.0.0.1 , localhost same though are. recommend changing hostname 127.0.0.1 or localhost , see happens.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -