root#localhost access denied for MySQL on mac system restart - mysql

I have Mac and installed MySQL in it for db connections and currently I am using laravel 8.
Everything runs smoothly until I restart or turn off my system .... The problem it causes is .. it throws me an error ...
i.e root#localhost access user denied for user
But the strange part is I haven't changed it anywhere neither I touched MySQL nor any manipulations in settings but somehow it is giving me this error....
For the solution I have searched and tried to recover my password and at last I had to delete all the db and alter my root password but it resulted in all data deletion ...Now I was working fine but again as I restarted my machine it again showed me that error.... Now my question is what actually happening here..
The problem in short is as soon as I restart my system my MySQL password starts giving an error having wrong password everytime..
So any helps or any hints what actually the problem is ...Maybe there is some mis configuration or settings issue .
Thanks in advance

Related

Win Server 2019 - XAMPP - MYSQL Access denied for user ''#'localhost' (using password: NO)

I've been browsing the web and this site from other users which have had this issue and reading the comments to resolve however I've not had much luck and i'm going bonkers trying to work out the issue.
I have two servers - Win Server 2019 and both use XAMPP with Apache and MYSQL, the first server (1) has been running for over a year perfectly fine, however I'm setting up another server (2) to use as a test environment but with a fresh install of windows, xampp along with the Apache/MYSQL modules.
I'm using Invision Community application but I'm getting this upon the first page of installation:
MySQL Requirements
Fatal error: Uncaught mysqli_sql_exception: Access denied for user ''#'localhost' (using password: NO) in C:\xampp\htdocs\ips4.php:317 Stack trace: #0 C:\xampp\htdocs\ips4.php(317): mysqli->__construct('localhost') #1 C:\xampp\htdocs\ips4.php(340): my_mysqli->__construct('localhost') #2 {main} thrown in C:\xampp\htdocs\ips4.php on line 317
IPS4.php is just a file to state whether the server meets all the requirements for the application.
I've then compared MYSQL on (1) to the install on (2) and I've matched the details, given privileges to "root" user on all of the available databases within PHPMYADMIN, granted full grants and then reloaded them, restarted MYSQL and Apache and still same issue.
Normally the Invision software continues through to then request the database details, user details etc. but it hasn't got to that point yet.
The only differences I can see between both servers is (1) is running PHP 7.3.7 | Apache 2.4.39 | MySQL 5.0.12 and server (2) is running PHP 8.2.0 | Apache 2.4.54 | MySQL 8.2.0
I was hoping I would just install XAMPP and then transfer the files to install the software and then configure it to choose which DB/User and then install and get started but apparently not.
ROOT doesn't have a password on (2) but does on (1), when I add a password to (2), I'm then unable to access PHPMYADMIN and doesn't ask for a password to log in. I've spent a few hours today trying to resolve this but now I think I'd like some advice. Many thanks
Setting root password, then flushing privileges, granting full permissions on all databases, copying the mysql files from server (1) to server (2). uninstalling XAMPP and reinstalling.
I don't recall ever needing to do anything for permissions when I setup this software on server (1). I've also installed this software on a few linux servers but didn't enjoy using linux so I stopped using it.
EDIT: It seems it's using MariaDB 10.4.27
Set a password for root on (2).
Change the phpMyAdmin config.inc.php file,change
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
then phpMyAdmin will throw a login dialog and ask for a user/password
That should sort out the phpMyAdmin issue.
Big Note: You really should not be using the root account for any app/website access. Instead you should create a user account in MySQL/mariaDB one for each app/website that has access only to the database(s) required for that app/website. (Basic Security)
There was a user called "Any" hostname "%" which looks to be what was causing the issue, I gave it access to all databases (most likely wrong thing to do but it's internally accessed only - no access outside of our network).
This got rid of the error
Thanks for your help

EasyPHP 16.1 DevServer Fresh install mysql issue

I've done a fresh install of 16.1 on two machines and ran into the same issue on both so I'm going to assume its not just me.
Windows 10 - Latest updates and all.
First, I'm getting fatal javascript errors all over phpmyadmin in firefox but thats a whole other issue (maybe).
I set up a global root user that I use to import databases from remote servers. My name rick#'%' by running the following command:
grant all privileges on . to rick#'%' identified by 'somepass';
Success. Ok great.
Try to run an import. Fails permissions.
I go and look at the mysql.user table and I see at least one problem the other is just plain weird.
1 - All privilege fields are ticked to N and not Y.
2 - The weird one, I have my password hash saved in the "plugin" column and not the "authentication_string" column. I'll get to why thats kinda weird to me in a minute.
So anyway I manually edit the user, changing all N to Y and move the password string to to the authentication string field.
flush privileges
Try to import again - it works.
Ok great, now I need to set up the user account for that database so again, I:
grant all privileges on dbname.* to dbuser#localhost identified by 'somepass';
Ok seems to work, I can load the site and browse... that is until I have to restart mysql or reboot my machine or something. Then once that happens I try to run the website and I get hit with this error:
mysql said: Unknown plugin '*HFDGYHUFJEFGHOIFJEFLEJIJCFIRG" bla bla bla
Ok.... I go and look at the user table and low and behold the password string is in the plugin field... but wait a minute, how was this even working at all up until the restart? Thats just confusing as hell.
Anyway, again, I move the password string to the authentication string field and flush privileges and boom it works.
SO I ask simply, why the is the fresh install of mysql on easyphp devserver 16.1 so funged up?
Is anyone else having issues like this?
Is there any way to manually fix this?
One thing I found weird was there is still a password field in the mysql.user table. Is this the problem? I thought they got rid of that column? maybe I'm wrong IDK.
So it turns out the mysql service was being delivered with the package in a state where it needed to have the "mysql-upgrade" command ran on it. I had to run the command to fix another issue I was having and after I did that user passwords are saved in the proper field. I would post the full command I used but that was a few weeks ago and I dont have it handy right now.

phpmyadmin MySQL access error

I am having issues attempting to access a local phpmyadmin; and I'm sure some people may have run into this issue before.
The issue seems to be arising from previous installations and configurations.
I have IIS installed, which naturally takes up port 80. However I have successfully installed WAMP and attached it to port 8080 so as to avoid conflicts. I have installed phpmyadmin to run from both platforms, however neither is working.
Through IIS the browser throws a 403.14 - Forbidden error whilst through WAMP phpmyadmin returns the following message
MySQL said:
1045 - Access denied for user 'root'#'localhost' (using password: NO)
I believe that at least one of these errors is due to an earlier installation of Wordpress through WebMatrix (which has gone predominantly unused) which changed the MySQL (5.1) username and password defaults.
Googling the issue resulted in what seemed a promising source which claimed that one can edit a file called config.inc.php which contains the password details which are used by phpmyadmin to log into the local MySQL db. However, I couldn't find such a file (instead one named config.sample.inc.php which contained some similar information contained in the tutorial, but crucially without the relevant password field).
This isn't an absolutely critical issue as hosted dbs are ultimately necessary, but local versions nevertheless ease development.
in case you do not find config.inc.php then you can create one..
for details you may check this link..

MySQL and PhpMyAdmin config.inc.php Password issue on MAMP

This is a very strange issue that is similar to a few other people issue that has been going on for a while with MAMP.
I recently upgraded to MAMP2 and followed the instruction for the new phpMyAdmin and it work for a while but recently whenever I try to connect to MySQL I always get this error:
Error: Could not connect to MySQL server!
/Applications/MAMP/Library/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'#'localhost' (using password: YES) when trying to connect
So I changed the password to the correct one and changed all the files as per advised on this forum topic: http://forum.mamp.info/viewtopic.php?f=2&t=11974.
But it did not work at all. I realized that there was two phpMyAdmin folder on my Mac one which is in
/Applications/MAMP/Library/bin/phpMyAdmin
and the other one in
Library/Application Support/appsolute/MAMP PRO/phpMyAdmin
In the first folder the config.inc.php as the correct credential for the user, however the second as root for both username and password. Obviously I tried to changed that but to no avail, the file is somehow always reverted to the default credential.
Did someone ever had this issue? is there a way to solve this?
I forgot to update this, if anyone is interested I got the fix for this (and I know many people had a similar issue).
In mamp.pro.global.preferences.plist is listed the encoded MySQLRootPassword, if like me you did update of your MAMP overrite this password field with your old one and there you have it, it works !
The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why.
Or alternately go to 'Operations' tab of any database to set it up there..

MySQL Password Not Working

EDIT: I had MySQL installed twice on my machine (XAMPP & on its own)
When I enter my password into MySQL Command Line Client, it rejects my password, gives 1 beep and closes the window. Can anyone provide me with a basic troubleshooting list of steps (from simple to progressively more technical) to regain entry into MySQL once and for all. Also, can anyone tell me what can cause my password to suddenly be rejected? I am also running XAMPP and the MySQL service is both installed and running. Thanks in advance.
I remember when I first got this problem some months ago, if I recall correctly, I solved it by starting the MySQL service from Windows XP's Administrative Tool (something I did stopped the MySQL service and to this day I don't know what it was).
Now the problem has started back again but this time, when I checked Services, the MySQL service was already 'started'.
Any assistance will be appreciated. Thanks
I think I figured out why my password was not working. I had two versions of MySQL installed on my machine (XAMPP and MySQL 5.1). So I deleted the MySQL 5.1 and it worked.
For me (and my similar problem),
--password = mypass
didn't work, but
--password="mypass"
did.
Is there an error message when it rejects your password? I wonder if perhaps you are using an outdated client and running into this issue: http://dev.mysql.com/doc/refman/5.1/en/old-client.html
If you set mySQL to not begin running on startup, then you need to start it prior to attempting to login. This can be done via the command line, via the task manager if you configured it as a windows service, etc.
For example, here is an explanation of starting the service using cmd
Starting MySQL from the Windows Command Line | MySQL
Do you have the password for the root account? If so, try this from the command line?
mysql --user=root --password=your password here
or
mysql --user=root --password=your password here --database=MySQL
A bit too late but - If you have numeric characters in your password and are using the numpad on your keyboard, ensure that the numlock is ON. For some weird reason if you have numlock off MySQL will still interpret a keystroke. This wasn't very obvious to me since my laptop doesn't have a num lock indicator light, thats HP for yah :)
How to Reset the Root Password | MySQL
This is the services solution that was mentioned. Use this if you can't remember your root password.
I'd like to add another successful solution to this problem. I reran the installer (the msi), chose the repair option and everything was fixed.
My password suddenly worked again, so I took the following steps to change it:
Using Windows Command Prompt, navigate to MySQL's bin directory
Type: mysqladmin -uroot -p password yourNewPassword
Press Enter. You will be prompted for your password, enter it
If no error messages/beeps happen, your password was successfully changed
Log in using MySQL Command Prompt with your new password
What I don't understand is that WHY all of a sudden my password started back to work after approximately 24 hours? I wish I know so I can avoid this in the future.