MySQL Connection Failed - php

I want to build a website on Ubuntu 14.
I have apache, PHP and Mysql installed on it.
I'm using PHP to connect to Mysql but got the error information as follows:
Connection Failed: SQLSTATE[28000][1045] Access denied for user 'root'#'localhost'
Anyone know how to fix it?

Probabbly Wrong Password issue or you didn't set the password for root yet. Try login from terminal using mysql -u root -p and it will asking your current root password.
If you are running a website, do not using root access for your website user access. Create an account with access to specified database.

Related

Can't solve mysqli::__construct(): (HY000/1045): Access denied for user 'root'#'localhost' PhpMyAdmin erorr

I am trying to connect to my db through phpmyadmin but I can't get connected no matter what solutions I try.
I am able to connect to the phpmyadmin screen but when I try to access my webpage I am met with the error.
Here it is expanded.
mysqli::__construct(): (HY000/1045): page error
I'm trying to access the path xampp/htdocs/pfs (my site).
I am using port 4306
xampp config panel
my username/password is root and no password
config.inc.php file
db_connection.php file
Here's my phpmyadmin root user information too
phpmyadmin
Is there another file path the phpmyadmin reads username/password information from that I'm missing ? Or am I trying to access my webpage in the incorrect way ? I can't figure this one out.
If anyone can help I'd appreciate it.
I've tried about 20 thread solutions from stackoverflow that were titled with the mysqli::__construct(): (HY000/1045): error
I am expecting to be able to view my webpage through htdocs and then be able to show CRUD statements.
Here's what I tested.
Changed port to 4306 in xampp config, config.inc.php and sql my.ini file
Changed password to root & " " in both db_connection.php and config.inc.php (this stopped me from accessing phpmyadmin altogether)
Changed hostname to localhost:4306 (this stopped me from accessing phpmyadmin altogether)
you need to add database name in mysqli function call:
$mysqli = new mysqli("localhost","root","","database_name");
https://www.php.net/manual/en/mysqli.construct.php

ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database (MySQL - MariaDB)

I'm currently making a simple app using Laravel and Xampp. While trying to connect the database and make migrations I got this error message from php artisan:
PHP error
So I decided to configure the database manually from the MySQL MariaDB shell (having started the session as the root user), but regardless of what user I try to gran privileges to on any database I get the following error:
MariaDB error
The only possible reason I can come up with is the fact that there seems to be two different root user listed, but I don't thisnk this is the root of the problem, since I'm starting the shell as root, and not choosing one of these after starting.
User List
I've already triple-checked my root user password (I've been starting the shell with this command mysql -u root -p -h 127.0.0.1). Trying to do this through the PHP MyAdmin interface yields the same error.
I'd appreciate any insights, thank you!
The multiple entries for 'root' are specifying which host addresses are allowed connections from (127.0.0.1 and % respectively)
Your error appears to be because your configured database connection (in Laravel) is using the user 'usario'. Search your files for where usario is defined and input the proper credentials to connect to your database in its place.
This is a common error when credentias supplied to MySQL/MariaDB are simply invalid. Bad username, bad password, or both. In this instance it looks as though you're trying to run a migration with a user that doesn't exist.

mysql error 1045 access denied php

I am trying use this guys code: https://github.com/daveismynamecom/loginregister in a xampp enviroment. My first error was a connection error. It was easy to solve and just had to cahnge the connection PDO in the config file. Now I get a
SQLSTATE[HY000] [1045] Access denied for user 'database username'#'localhost' (using password: YES)
error. I have looked at every stack q&a and have not found an answer. I didnt change the code from this guys website other than the PDO. any help would be great. Also this was my first time install xampp and I didnt have msql or php before this
[edit] I have never used mysql so how would you set up root permissions and setup a root user. I can log in to the root user from the mysql console by leaving the password blank but I don't know if that is it
[edit v2] I needed to add the user :). Did not know that. but now I am getting a error code 1044 but that is a question for another time
It's not about the code itself - that error comes directly from your MySQL server. Check whether your credentials (user/pass) are correct.
[edited]
I have never used mysql so how would you set up root permissions and setup a root user. I can log in to the root user from the mysql console by leaving the password blank but I don't know if that is it
So did you set a blank password in the config file as well?

Php mySql with wamp access denied Error

at first Mysql had no problem ( can access db via mySql command line with my password) but when i run my php file with wamp server ,i receive this Error :
Access denied for user 'root'#'localhost' (using password: YES)"
.... and after that , not only that my php file raise an error , i get an access denied error trying to access my databases with mySql shell .
i ran these php file with xamp and had no problem , but after switching to wamp all these errors appear , any ideas ?
You need to set a new root password within your WAMP environment. It has a different instance of MySQL to the one in XAMPP, so it won't pick up the same root password. Change the root password and try connecting again, that should work.

Can't access mySQL remotely with PHP, how to fix?

So I have mySQL installed on Ubuntu and I'm trying to access it with PHP.
As long as I'm in Ubuntu, I can access mySQL from the command line without any issues. However, with PHP, I can only connect to mySQL. Once in, though, it refuses to let me select a database. I've enabled all permissions to the user alias that I'm connecting with, and even allowed remote access to the database.
As root, PHP shows the following error:
(1049) Unknown database 'my_database'
As the user alias I use (called 'default'), PHP shows a different error:
(1044) Access denied for user 'default'#'localhost' to database 'my_database'
What am I missing? This never happened until I upgraded to Ubuntu 10.11.
Grant your user privileges to that database with the correct password:
GRANT ALL PRIVILEGES ON my_database.* TO default#localhost IDENTIFIED BY 'thepassword'

Categories