Why does MySQL always give error access denied even though user exists? - php

I'm trying to simply run php artisan migrate --seed on a new Laravel project but everytime I try, I get the error:
SQLSTATE[HY000] [1045] Access denied for user 'appuser'#'localhost' (using password: YES)
I check my database config file and the correct username and password for the database are there.
I check MySQL Workbench, and the correct user is there with all the schema privileges for the same password.
I tried adding the user with privileges under %, localhost and 127.0.0.1 but same access denied error.
I ran a quick check to make sure Laravel was selecting the right environment for the database connection details and it is.
I've created users hundreds of times and never had this problem. This all started after I updated to the latest MySQL Workbench 6.1.7 after the older version stopped working correctly on Windows 8. Sadly, I don't have the option to even go back and test if the old version fixes the problem since it won't work at all.
At this point I can't get any new database users to connect.
The database server is up and running, and every other previously existing user still connects just fine.
Here is the my.ini file.
Any ideas? I'm hoping I'm just tired and missing something obvious here.

by reading the config file.
[client]
password = mysql
port = 3306
socket = "{$path}/mysql/mysql.sock"
i think you need to comment the string with default password. Probaby it affects something.
I have recent MariaDB, and the password string is commented out in every config file example

Related

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.

phpMyAdmin connects only if --skip-grant-tables is active on the db server

I have a weird issue where I'm trying to connect phpMyAdmin to a remote server. It wasn't working at all so I was messing around with mysql in command line on the db server (no phpMyAdmin on the db). I used skip-grant tables so I could reset the root user and add myself as a user with all privileges:
GRANT ALL PRIVILEGES ON *.* TO 'myusr'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
I accidentally tried logging into PHPmyadmin at this time and it worked! Full access - can see everything in the remote DB. I know it's connected properly because changes I made in command line were showing in phpMyAdmin on the web server.
Now I stop mysqld_safe and restart the service on the db and everything dies again. I keep getting the unhelpful "Cannot log in to the MySQL server" message on phpMyAdmin without any other information. I tried tracing the connection in phpMyAdmin and setting values to test the db connection and results, but that's not working as well as I hoped.
I'll keep hacking, but I'm hoping someone has an idea what to do in this case? All the values appear to be configured correctly since it DOES connect to the db if I turn off all security. I can log into my user commandline using the same name and pass on the db server.
What else could I be missing?
EDIT: I stopped being dumb and trying to hack phpMyAdmin and made my own test php script that simply runs a mysqli_connect() attempt and returns the detailed error. I'm getting the following:
SQLSTATE[28000] [1045] Access denied for user 'myusr'#'prodserverFQDN' (using password: YES)
Ok. I kept researching while waiting for a response and I found something that works. Apparently I didn't enclose my password in quotes or something when I created the user commandline.
To fix it, I used mysqld_safe --skip-grant-tables on the db server so I could log in with phpMyAdmin. Using phpMyAdmin, I edited the user to change the password (via edit, not SQL to prevent shennanigans). Now I can log in like normal without using the "no security" option on my db server.

phpMyAdmin password reset

I am running a ReadyNAS 102 and installed MySQL, PHP and phpMyAdmin to setup a database for use with OwnCloud. The first install was successful, but after forgetting some login passwords I decided to go for a full reinstall of the above.
Now, when opening phpMyAdmin, I get the following message:
#1045 Cannot log in to the MySQL server
I understand from other sites that I need to access the config.ini.php file to edit the user details manually (and reset the root), however I have no idea how to access this file on the NAS. Is there a command line access for files on the NAS?
https://www.ostraining.com/blog/coding/error-1045-phpmyadmin/

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 5.4 old auth on shared server, fixing without editing the mysql server

I just upgraded my developement box's PHP to the latest version, 5.4.5. This developement machine connects to a remote MySQL server, residing on a shared server that I lease from a hosting company.
Trying to connect to my remote MySQL server using simple mysql_connect('myserver.com', 'user', 'password') results in the following error:
Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in file.php on line 2
Simply, as advised, just executing:
SET PASSWORD = PASSWORD('my-password');
wouldn't change anything.
The same applies when executing
SET SESSION old_passwords=FALSE;
After a bit of searching, I realized that I needed quite deep access to the MySQL server to be able to fix this problem, which I do not have. Trying to execute this query:
UPDATE mysql.user SET Password=PASSWORD('my-password')
WHERE User='my_user' AND Host='my-server';
FLUSH PRIVILEGES;
Simply gives me the following error:
1142 - UPDATE command denied to user 'u0112918'#'www10.aname.net' for table 'user'
Requests to have the company execute the query for me has, so far, been unsuccessfull. So my question is if there's any way to fix this on the client side, without involving the MySQL server?
Hm, try executing the following query through a tool other then PhpMyAdmin, such as Mysql Workbench or through a shell:
SET SESSION old_passwords=0;
SET PASSWORD = PASSWORD('passwordString');
You should be allowed to change your own password without DML Rights on user-table.
Edit: since it did not resolve the issue - when "read_only" is enabled for the database then you need super rights to change (even your own) password ( http://dev.mysql.com/doc/refman/5.5/en/set-password.html )

Categories