Connecting to mysql in xampp without password - php

I want to configure the mysql xampp password to no password. I opened the my.ini and I saw the following line:
# password = password
I I don't use password what should I type?
And that's the error I get when I try to connect to mysql through php:
mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using
password: YES) in C:\xampp\htdocs\spikes\functions.php on line 53
Failed to connect to MySQL: Access denied for user 'root'#'localhost' (using password: YES)
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in
C:\xampp\htdocs\spikes\home.php on line 6

If you haven't set a password for MySQL (check by opening the MySQL config through XAMPP), just put "" as the password. Make sure your PHP script is also configured to use that as the password, because it is currently trying to use one (hence the Using password: YES).

Related

mysql_query(): Access denied for user ''#'localhost' (using password: NO)

I'm running a cron job in my WordPress site and getting these two errors
Warning: mysql_query(): A link to the server could not be established in /home/geekda6/public_html/wp-content/plugins/maxblogpress-ninja-affiliate/ninja-affiliate-library/include/mbp-ninja-affiliate.cls.php on line 251
Warning: mysql_query(): Access denied for user ''#'localhost' (using password: NO) in /home/geekda6/public_html/wp-content/plugins/maxblogpress-ninja-affiliate/ninja-affiliate-library/include/mbp-ninja-affiliate.cls.php on line 267
Invalid query: 1045: Access denied for user ''#'localhost' (using password: NO)
Here is my file.
https://gist.github.com/amarilindra/d89a0e2b90615e0f0c28
The application is trying to connect to the MySQL database without a user (anonymous). Did you check if the MySQL instance allows anonymous access?
Just run mysql. If you get the same response, than that is your problem.
Posible solutions:
configure your application with a mysql username/password.
https://codex.wordpress.org/Installing_WordPress
configure mysql for anonymous access (not recommended).
This is the default, so someone must have set it up with a user.
How are you running mysqld?

mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'uname'#'localhost' (using password: YES) in /all_pts.php on line 16 [duplicate]

This question already has answers here:
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
(43 answers)
Closed 7 years ago.
Although I successfully connected to wamp server facing the problem as above when uploaded the data and php file using FTP on a remote server.
I tried all password/username combination.
I used with this web hosting but in-vain. Please suggest something that may be obvious but not getting.
mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'uname'#'localhost' (using password: YES) in /all_pts.php on line 16
You need to create database and database user via control panel of your hosting account. Mostly cPanel is used for it. Then you need to put information of the database and database user into all_pts.php
See How to create a MySQL database in cPanel

MySQL Error - Php

When I go to the page, I get 4 errors, but when I execute the script it works perfectly and once it reloads the page after the scirpt has executed the errors go away. And the thing is I am using a password to connect and I am not connecting to localhost.
Warning: mysql_query() [function.mysql-query]: Access denied for user 'a1160699'#'localhost' (using password: NO) in /home/a1160699/public_html/stockupdate/index.php on line 16
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/a1160699/public_html/stockupdate/index.php on line 16
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'a1160699'#'localhost' (using password: NO) in /home/a1160699/public_html/stockupdate/index.php on line 17
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/a1160699/public_html/stockupdate/index.php on line 17
This error indicates that you have invalid MySQL credentials - either the user does not exist, or the password you're using is wrong. It appears that you're not using any password, so you might have just missed to input the password.
In case the username and password are correct, you should make sure that this user has the necessary permissions to interact with this database.
Warning: mysql_query() [function.mysql-query]: Access denied for user
'a1160699'#'localhost' (using password: NO) in
/home/a1160699/public_html/stockupdate/index.php on line 16
This line is indicating that your user you have set in your connection array does not have the required permissions and/or does not exist on the server you are attempting to run your code on. You will need to check that the username and password matches one that has the correct permissions on your MySQL server.
EDIT
<?php
$username="a1160699";
$password="passwordHere";
$database="a1160699_rsg4s";
mysql_connect("mysql3.000webhost.com", $username, $password);
mysql_select_db($database) or die( "Unable to select database");
?>
Try this code in your connect.php file. This is MySQL to fit your code but I would strongly suggest you look at MySQLi or PDO.
If you are using a password for the localhost server then please connect your application in localhost server like this.
mysql_connect('localhost','root','your passwrd');
mysql_select_db('your databse name');
After you can execute your query to database then it will work fine..

I want connect.php file should be run in local host. But as follow error there

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'test'#'localhost' (using password: YES) in D:\xampp\htdocs\ngp\connect.php on line 2
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'#'localhost' (using password: NO) in D:\xampp\htdocs\ngp\connect.php on line 4
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in D:\xampp\htdocs\ngp\connect.php on line 4
This means that the username/password in your connection file is wrong, or that access to the server is not allowed from the machine you're trying to connect from.
This is telling you that the user test and the password you used were not valid and the user ODBC using no password was invalid. Either because they are just wrong or because the users are not allowed to connect from the machine you are connecting from. E.g. if you are connecting remotely from your local machine to a hosted machine.
Check the MySql usernames and passwords you have set up to connect to your database.
Also, show some code!

How to resolve "Access denied for user 'drngpasc'#'localhost'" Error?

Hai Alex
Thank you for your answer.One more error as follow:
Warning: mysql_connect()
[function.mysql-connect]: Access
denied for user 'drngpasc'#'localhost'
(using password: YES) in
D:\xampp\htdocs\ngp\connect.php on
line 2
Warning: mysql_select_db()
[function.mysql-select-db]: Access
denied for user 'ODBC'#'localhost'
(using password: NO) in
D:\xampp\htdocs\ngp\connect.php on
line 4
Warning: mysql_select_db()
[function.mysql-select-db]: A link to
the server could not be established in
D:\xampp\htdocs\ngp\connect.php on
line 4
The first and second errors means that you have a mistake in connection config. May be you use wrong login or password to db. Check you database config, may be connect with this login is denied for example.
The third error means that you want to select databse, but you not connected to database server.
There is a problem with your user ID and password to login to MySQL. If its a local WAMP/LAMP setup - try user:root pass:(blank) user:root pass:root.
Is MySQL installed and running? Do you have a user account drngpasc on your local MySQL install. Do you have a password on that account (if you have an account, yes you have a password in this case).

Categories