LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-18-2019, 12:37 PM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Rep: Reputation: 34
PHP : Access denied for user 'MyUser'@'localhost' but IP given


Hello

I get error : Access denied for user 'MyUser'@'localhost' (using password: YES)

But what I find strange is where this "localhost" comes from ?

My code :
Code:
$logdb=mysqli_connect("11.22.33.44", "MyUser", "MyPasswd", 'logging');
if (mysqli_connect_errno()) {
    echo "MySQLi conn err: " . mysqli_connect_error();
}
My Users :
Code:
MySQL [(none)]> select Host, User from mysql.user;
+----------------+--------------+
| Host           | User         |
+----------------+--------------+
| %              | scripter     |
| %              | jonaskellens |
| %              | root         |
| 11.22.33.44   | MyUser       |
| localhost      | mysql.sys    |
+----------------+--------------+

Last edited by jonaskellens; 06-18-2019 at 03:26 PM.
 
Old 06-18-2019, 01:08 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by jonaskellens View Post
Hello

I get error : Access denied for user 'MyUser'@'localhost' (using password: YES)

But what I find strange is where this "localhost" comes from ?

My code :
Code:
$logdb=mysqli_connect("11.22.33.44", "MyUser", "MyPasswd", 'logging');
if (mysqli_connect_errno()) {
    echo "MySQLi conn err: " . mysqli_connect_error();
}
You need to be a bit more clear about where you are connecting to and from.

Is 11.22.33.44 a remote host or the same machine your PHP code is running on?

Is the user table data from the remote machine or the local machine (or are they the same machine)?

There is an apparent error in the user table data, higlighted below...

Quote:
Originally Posted by jonaskellens View Post
My Users :
Code:
MySQL [(none)]> select Host, User from mysql.user;
+----------------+--------------+
| Host           | User         |
+----------------+--------------+
| %              | scripter     |
| %              | jonaskellens |
| %              | root         |
| 11.22.33.440   | MyUser       |
| localhost      | mysql.sys    |
+----------------+--------------+

Last edited by astrogeek; 06-18-2019 at 01:08 PM. Reason: tpoy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i tried using this code for deleting a user given character from a user given string mecrazyme1234 Linux - Newbie 2 06-04-2011 04:59 PM
i tried using this code for deleting a user given character from a user given string mecrazyme1234 Programming 7 06-04-2011 11:47 AM
myuser symbolic link JeffDrechsler Linux - Server 1 09-30-2007 11:41 PM
k3b: unable to open '/tmp/kde-myuser/k3b_image.iso' for writing xpucto Linux - Newbie 4 12-28-2006 05:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration