MySQLi - Can't find the user - php

I'm trying to create a connection to my MySQL database through MySQLi by using the following code:
$con = mysqli_connect( "localhost", "wesley", "", "project_tim" );
Now, my error (well, warning) is the following:
Warning: mysqli::mysqli(): (HY000/1044): Access denied for user ''#'localhost' to database 'project_tim'
As you can see, there is no user in the error line. What can the problem be? I have the latest version of Xampp, the user is created and both services are running.

Finally the problem is wesley user don't have the permission to access the database.
To provide permission for wesley user, run this command in your MYSQL console or in phpMyAdmin
GRANT ALL ON project_tim.* TO 'wesley'#'localhost';
And restart your xampp

Related

Can't connect to MySQL database from Laravel, even though I created the required user

I'm getting this error when I open a view that requires data:
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from `books`)
I created the homestead#localhost user in MySQL with the specified password, but I'm still getting the error... What might cause this and how can i fix it? Thanks! :) (I already tried restarting the php artisan serve process and running php artisan config:clear...)
This is really stupid but Laravel was lying about the password it was using; it was actually "secret" as defined in the .env file!

Reverting a grant privileges statement in MySQL

So I'm hacking away at some software and I decide to run the MySQL command
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password';
Then I notice that my Bug tracker uses the same local MySQL server on my development PC.
Well darn ..
Now when I try to use my bug tracker (Mantis), I get an error message.
APPLICATION ERROR #400 Database connection failed. Error received
from database was #1045: Access denied for user 'root'#'localhost'
(using password: NO). Please use the "Back" button in your web
browser to return to the previous page. There you can correct whatever
problems were identified in this error or select another action. You
can also click an option from the menu bar to go directly to a new
section.
Previous non-fatal errors occurred. Page contents follow.
SYSTEM WARNING: 'mysql_connect() [function.mysql-connect]: Access
denied for user 'root'#'localhost' (using password: NO)' in
'C:\xampp\htdocs\mantis\library\adodb\drivers\adodb-mysql.inc.php'
line 365
I checked inside the php file and that line is where the MySQL connection is established
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!empty($this->port)) $argHostname .= ":".$this->port;
if (ADODB_PHPVER >= 0x4300)
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
$this->forceNewConnect,$this->clientFlags);
else if (ADODB_PHPVER >= 0x4200)
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
$this->forceNewConnect);
else
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}
Using MySQL Workbench I can see that
SHOW GRANTS;
That first row seems to be the culprit, ... I think ...
Is there a way to revert this?
Thanks :)
I've managed to get mantis working again by
SET PASSWORD FOR root#localhost=PASSWORD('');
As recommended here

can't use the XAMPP CD Collection program

I just installed XAMPP 1.8.2 for Windows.
I changed security settings for accessing the MySQL db and now that I run CD Collection (under Php in the menu on the left) I get this error:
Warning: mysql_connect(): Access denied for user 'root'#'localhost' (using password: NO) in C:\xampp\htdocs\xampp\cds.php on line 78
Could not connect to database!
Is MySQL running or did you change the password?
So I changed the password yet it's trying to access the db with the user root and no password?
I've read that you have to flush privileges but I'm not sure how I can do that, do I have to access the userlist in phpMyAdmin and update something there?
You need to change the password in the cds.php file located at [xampp folder]/htdocs/xampp/cds.php . The credentials need to be filled in on line 5:
mysql_connect("localhost", "root", "");
Place your new password between the quotes.
Also do this on line 78:
if(!mysql_connect("localhost","root",""))

xampp mysql: select command denied

I am using xampp om windows 7. I logged in as the root user with the password i have set up. I created a new database(I am using xampp for the first time). and I am not getting any option for creating any tables in it.
It shows the following error:
Error
SQL query: DocumentationEdit
SELECT `tables`
FROM `phpmyadmin`.`pma_recent`
WHERE `username` = 'root'
MySQL said: Documentation
#1142 - SELECT command denied to user ''#'localhost' for table 'pma_recent'
How do I get rid of this?
I get this line also, somewhere at the bottom of the page along with the error message:
The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated.
http://dev.mysql.com/doc/refman/5.1/en/grant.html
GRANT SELECT ON db.table TO 'user'#'localhost';
GRANT ALL ON db1.* TO 'jeffrey'#'localhost'; ------------ i think this is much better.

Agile Toolkit 4 (ATK4) database connection failed

I'm trying to get the examples to work in Agile Toolkit, but I get the database connection failed error. I created a MySQL database, imported the schema.sql file, and updated the config.php file with the correct database name, database username, and password.
Here's the DSN line in config.php (fake username:password substituted)
$config['dsn']='mysql://admin123:pw12345#localhost/ATKexample';
It seems to be pointing to the right place, because the error changes if I put the wrong password into config.php. The first error message below is what I get with the correct password, and the second one below is what I get if I use an incorrect password.
PDO error: SQLSTATE[42000] [1044] Access denied for user
'admin123'#'localhost' to database 'ATKexample'
PDO error: SQLSTATE[28000] [1045] Access denied for user
'admin123'#'localhost' (using password: YES)
I can't figure out what I'm doing wrong. I don't know if it is a problem with the way the MySQL database is setup or if I need to change something in my ATK example files. Can anyone suggest a troubleshooting strategy?
Edit: I didn't have my user privileges setup right in MySQL. Problem solved.
Log into your mysql console and grant permissions for user admin123
grant all on `ATKexample`.* to 'admin123'#'localhost' identified by 'pw12345';

Categories