Used code for connection
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword);
?>
current settings:
^User name, Host name, Password, Global privileges, User group, Grant^
Error:
Warning: mysqli_connect(): (HY000/1045): ProxySQL Error: Access denied for user 'root'#'2a02:4780:bad:f00d::16' (using password: NO) in /storage/ssd3/007/15887007/public_html/dbh.php on line 5
I'm using 000webhostapp.com for my website and XAMPP for database
You didn't add database name.
$dbname = 'your db';
Related
I copied this from W3Schools and when I try to run it it gives me the a error. I am really new to MySQL so I am trying to fix this but I don't know how.
ERROR:
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user
'username'#'localhost' (using password: YES) in
C:\xampp\htdocs\Informatica\test.php on line 10 Connection failed:
Access denied for user 'username'#'localhost' (using password: YES)
<html>
<body>
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
</body>
</html>
your username or password is incorrect if you are very new and just starting with the local server try
$username = "root";
$password = "";
as your username and password
W3schools don't know your localhost details, do the following
$servername = "localhost";
$username = "root"; //put your username here
$password = ""; // your password here
Leave password empty and put "root" in username, that's the default xampp setting.
you have to add correct information provided by your hosting provider here :
$servername = "localhost";
$username = "username";
$password = "password";
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
//Connection to mysql check
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
mysqli_select_db($conn,'databaseName');
?>
I am trying to access a PHP database I created online using this URL
http://dns.com/data_api/connect.php
I have created the database and it has no username and password attached to it at the point of creation. When I try to check if the connect.php could establish a connection to the database I get this error
Warning: mysqli_connect(): (28000/1045): Access denied for user 'mobileto'#'localhost' (using password: NO) in /home/mobileto/public_html/data_api/connect.php on line 11
Failed to connect to MySQL: Access denied for user 'mobileto'#'localhost' (using password: NO)
This is the connect.php file
<?php
$username = "";
$password = "";
$hostname = "localhost";
$dbase ="mobileto_holo";
//connection to the database
//$dbhandle = mysql_connect($hostname, $username, $password)
$con=mysqli_connect($hostname,$username,$password,$dbase);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";
//$conn = mysql_connect("localhost","root","");
?>
Please what could be wrong?
No Username or Password? :o That's impossible. Try giving root as the default username, instead of passing an empty string.
$username = "root";
$password = "";
$hostname = "localhost";
$dbase = "mobileto_holo";
I am trying to connect to MySQL on the server but gives following error. User is created and granted all privileges.
It's working on local machine but not after deploying to a server.
Also mysql_connect function works but new mysqli() gives access denied as mentioned below.
Also Tried adding port.
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user ''usernam'#'localhost' (using password: YES) in /home/domainname/public_html/autopublish/test.php on line 8
Connection failed: Access denied for user ''username'#'localhost' (using password: YES)
<?php
$servername = "localhost";
$username = "'xxxxx";
$password = "xxxxx";
$dbname = "xxxxx";
// Create connection
$conn = new mysqli($servername, $username, $password); **//line 8**
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
echo "no connection";
}
$sql = "SELECT * FROM pages";
$result = $conn->query($sql);
$data = array();
$arr = array();
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
}
} else {
echo "No Token";
}
print_r(json_encode($data));
$conn->close();
?>
Either the user does not have the required rights for the database or the password is wrong.
Otherwise remove the user and use the following statement to create:
1.CREATE USER 'user'#'localhost' IDENTIFIED BY '123456789';
2.
3.GRANT ALL PRIVILEGES ON project.* TO 'user'#'localhost' WITH GRANT OPTION;
or try this:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "dbname";
//Create
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$conn = new mysqli($servername, $username, $password, $dbname);
echo "Yaaay";
Warning: mysql_connect(): Access denied for user 'root'#'10.2.1.12'
(using password: NO) in
/home/u749031689/public_html/Enrollment/includes/dbcon.php on line 8
Access denied for user 'root'#'10.2.1.12' (using password: NO)Not
<?php
$Server="localhost";
$unameDB ="root";
$passDB ="";
$dbName="u749031689_enrol";
$sqlCon = mysql_connect($Server, $unameDB, $passDB) or die (mysql_error(). "Not connected");
mysql_select_db($dbName, $sqlCon);
?>
You have to create your database to the hostinger server and then you need to replace your '$Server', '$unameDB', '$passDB' and '$dbName' values as per your hostinger database details.
Your code would be as follows.
<?php
$Server="YOUR HOSTINGERS DATABASE SERVER NAME";
$unameDB ="YOUR HOSTINGERS DATABASE USER NAME";
$passDB ="YOUR HOSTINGERS DATABASE PASSWORD";
$dbName="u749031689_enrol";
$sqlCon = mysql_connect($Server, $unameDB, $passDB) or die (mysql_error(). "Not connected");
mysql_select_db($sqlCon, $dbName);
?>
Hello everyone am trying to connect to MySQL database but getting this error:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) Error: Could not establish connection.Access denied for user 'root'#'localhost' (using password: YES).
Here is my code:
<?php
$host = "localhost";
$db = "resumedb";
$username = "root";
$password = "sa";
$phpConnect = mysqli_connect($host, $username, $db, $password);
//checking the if connection.
if($phpConnect === false)
{
die("Error: Could not establish connection.".mysqli_connect_error());
}
?>
The right syntax is:mysqli_connect("myhost","myuser","mypassw","mybd")
so try:
$phpConnect = mysqli_connect($host, $username, $password, $db);
refer this
Basically If you are the newbee in PHP so you should
1.first start the Xamp/Wamp service.
2.else db credentials for password should be $password = "".