I have a login script, PHP based. when I run the page I get the following error:
Access denied for user 'usernameI'#'mydomainname.com' (using password: YES)
I've confirmed my password and that the respective user has all rights to the database. I tested a small connection script and get the same error. Here is the code:
<?php
$con = mysqli_connect("mydomainname.com","usernameI","mypassword");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
...I have the above within the body tag of the PHP page. Could I get some help as to what I'm doing wrong or if there is something I've overlooked or need to confirm? Thanks!
Related
I am trying to install my php script on live server but am getting an error. I have already created a db/user and uploaded sql to my phypmyadmin
Error I am getting is
Access denied for user 'user'#'localhost' (using password: YES)
It's simply telling you that the username or password is not right, so you can't have an access.
Please check the password and the name of the user inside your php script, take a look at this.
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
?>
You see in your case you need to change these parameters to the ones in your live server.
$con = mysqli_connect("your_server","your_user","your_password","your_db");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
This question already has answers here:
MySQLI 28000/1045 Access denied for user 'root'#'localhost'
(2 answers)
Closed 6 years ago.
Hello i still getting this error...can anyone explain me why is there 10.2.1.19? because in my config db file there is localhost instead of 10.2.1.19..i tried to type 127.0.0.1 instead of localhost but nothing...still 10.2.1.19
My configdb file:
<?php
$mysqli=mysqli_connect('127.0.0.1','user','','table') or die(mysqli_error($mysqli));
?>
Thanx for help
Maybe because of User name and password. Pass valid username, password and DB Name
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Your code is:
<?php
$mysqli=mysqli_connect('127.0.0.1','user','','table') or die(mysqli_error($mysqli));
?>
You must to connect do database before try table
<?php
$mysqli=mysqli_connect('127.0.0.1','user','','DATABASE_NAME_HERE') or die(mysqli_error($mysqli));
?>
If this still doesn't work, try to set some password, '123' for example, and try connection again. I recommend you to use mysqli class:
$some_variable_name = new mysqli('server_name','user_name','password','database_name');
$some_sql_command = "your SQL without ; at final";
$some_variable_name->query($some_sql_command);
$some_variable_name->close();
Go to php.net manual and see all commands.
I'm not an expert in configs, .ini files and these things, so I can't tell nothing about the modified IP.
I'm trying to create a very simple create account page. This is the part of the MySQL Database connection:
<?php
function dbconnect()
{
$connection = mysqli_connect("localhost","maistral_quizonline","maistral_kalkas","abcdefghi");
if (mysqli_connect_errno($connection))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
return 0;
}
return $connection;
}?>
When I try to run dbconnect this is what I get as output:
"Failed to connect to MySQL: Access denied for user 'maistral_quizonl'#'localhost' (using password: YES)Access denied for user 'maistral'#'localhost' (using password: NO)"
Now, I'm new to php and maybe i do something really silly, can anyone explain to me this output? Why it seems to try for connection twice and why the connection information is corrupted? What is this: maistral_quizonl? maistral? Why is it cutting the words? And why the first time says that I'm using password and the second time says no? I hope my mistake is not so stupid.
And one other thing. I saw in another post someone suggesting to check if the mysqli_connect function exists so I change this:
echo "Failed to connect to MySQL: " . mysqli_connect_error();
to this:
echo "Failed to connect to MySQL: " . mysqli_connect_error() . var_dump(function_exists('mysqli_connect'));
and the output was this:
"bool(true) Failed to connect to MySQL: Access denied for user 'maistral_quizonl'#'localhost' (using password: YES)Access denied for user 'maistral'#'localhost' (using password: NO)"
lol?
I know that it's pointless to check if mysqli_connect exists after you use it but am I mistaken or isn't the "bool(true)" suppose to print at the and of the line and not the beggining?
What is going on?
Thank you
PS: I have double check that the database exists as well as the user and the priviliges and the password
mysqli_connect accepts parameters in this order 'host', 'username', 'password', and 'dbname', is this the order in which you have provided your details? It does not seem so.
http://us2.php.net/manual/en/mysqli.construct.php
I want to connect 2 diffrent DB, but I get that error:
Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user '*username*'#'localhost' (using password: YES) in......
my code:
$mysqli2 = new mysqli('localhost',$db_user,$db_pass, $db_name);
$mysqli2 = new mysqli('localhost',$db_user2,$db_pass2, $db_name2);
And I try to excute queries like this:
$result=$mysqli->query("select ......
$result=$mysqli2->query("select ......
How can I fix this?
Your username or password is wrong.
Your mysql user may not have the right privileges to connect over the network.
See here : How to grant remote access permissions to mysql server for user?
check password and adress and username
use next code to connect
$connect1 = new mysqli(...);
$connect2 = new mysqli()
if ($connect1->connect_error)
echo "error in 1 connection message: " . $connect1->connect_error;
if ($connect2->connect_error)
echo "error in 2 connection message: " . $connect2->connect_error;
where you see a problem ?
So I'm trying to set up a PHP site that accesses and writes to a database. This should be relatively simple but I've become swamped with a mess of permission issues and I'm new to PHP so I'm not sure how to fix them all.
First off, this warning occurs when trying to access the database:
Warning: mysqli_connect(): The server requested authentication method unknown to the client [mysql_old_password]
The connection also fails due to this:
Warning: mysqli_connect(): (HY000/2054): The server requested authentication method umknown to the client
In my research I found that this warning was related to password hashing due to versioning of PHP (link)
However attempting to run the solution on that page gives me the following error:
Error Code: 1044. Access denied for user 'user'#'host' to database 'mysql'
And I don't know how to gain permissions in that database.
Here's my php code for reference (sensitive info removed):
$con=mysqli_connect("IP:port","user","password","database_name");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "Succesfully connected";
echo "<br />";
}
$result = mysqli_query($con, "SELECT * FROM OWNERS") or die("Error: ".mysqli_error($con));
while($row = mysqli_fetch_array($result))
{
echo $row['email'] . " " . $row['type'];
echo "<br />";
}
Can someone help me out with this one? I know it's a lot but it seems like all of the issues are related and I'm not sure where to start with fixing them. (I'm using XAMPP to run the php and MySQL workbench to run queries)
I suppose the mysql is running on a different machine in your network. try this to see if it works:
CREATE USER 'user'#'IP' IDENTIFIED BY 'your password';
GRANT ALL ON database_name.* TO 'user'#'IP';
if the user is already in your system but with different IP then you should create it again using the IP of your mysql server. you could also try % instead of IP in create user and grant statements but it is not recommended in production.