MySQL root user suddenly not connecting using password - mysql

I was following a Ruby on Rails tutorial (fairly new to this language) and suddenly started having some problems connecting with MySQL on my Mac. While doing the tutorial I believe I changed the shell location using similar steps in this guide, not sure if that’s important at all.
My $PATH returns:
-bash: /Users/[MYUSERNAME]/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin://usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory
Anyway, I’ve been working through the tutorial and have been developing since then but I went to check my files a week or so later and suddenly cannot connect to MySQL at all, if I enter mysql -u root -p (then enter correct password as it always has been) I get:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I’ve got MySQL Workbench although I rarely use it, and I use the System Preferences App to start and stop my server. I also have MAMP which I was using a while ago but I haven’t used it since using RoR.
Strange thing is, this happened before and I couldn’t connect, I was searching around for ages trying to find a solution and (not sure what I did, probably nothing substantial) it started working again. But once again it’s happened and think it’s time I learnt what the problem is so I don’t keep running into it.
Personally, I think I should’ve learnt MySQL in more depth before blind-following a tutorial assuming it’d be fine.
Any help would be greatly appreciated, thanks!
Let me know if you need me to provide anything else.

Simple answer in the end, I followed this tutorial and was able to reset the root password and it fixed everything.

Related

Docker MySQL "Access denied for user 'root'#'localhost" outside of terminal

I know that this is a fairly common error, but the curious thing is that in this case the credentials work when I'm logged in to Docker and working with mysql in the terminal. But when I try to use a client like DBeaver or MySQL Workbench, or even making an API call via Python, I get the error "Access denied for user 'root'#'localhost".
I thought it might be because I have another local MySQL database using port 3600, so I changed it to 3700 but the problem persists. I've made sure that the image is running in the Docker application, and besides, as mentioned, it works using the terminal. This is on MacOS Ventura. If there's any other information I can provide that would help, please let me know. Any assistance is appreciated!

MySQL works only with --skip-grant-tables and can't go away from that. Linux

I was looking on almost every solution which I found on the web, but I still have this issue.
I can connect to mysql (either in terminal or phpmyadmin) when I run --skip-grant-tables, but without it it is totally not working (I am getting 1045 access denied).
I found this: MySQL only works with: skip-grant-tables but I can't run it, because I can only access mysql with --skip grant tables.
Any solutions? I really googled and tried a lot...
from a glance seems it's mysql user permissions problem. if, say, you connect with uname userone, it's just that userone does not have certain permissions on the tables and therefore you have to pass 'skip-grant-tables' option. easiest approach - log as root (admin or whatever god-like-mysql user) and grant your normal user (userone) the missing permissions. See this, there is example under "Account names and password"
http://dev.mysql.com/doc/refman/5.7/en/grant.html

Rails mysql can't connect using password yes

I install some old app build in Rails 4.0.0 and ruby 1.9.3 gems. Everything goes ok but when I go to rails console and try for example wrote : User, to get database table it give me error:
Mysql2::Error: Access denied for user 'root'#'localhost' (using password: YES)
What is interesting, when I do:
sudo /etc/init.d/mysql stop
It says that database was stopped but app still working :)
Can somebody tell what is going on?
Well - if the database tells you it's stopped, and your app is still working I can think of 3 possible causes.
The database is still running, and you've been lied to
The app does not need a database to respond to the requests you make
The app is using a database elsewhere.
The most obvious way I can think of, it to have a look at config/database.yml, there you can see what database your app is connecting to, and the username/password. If it's not the one you've stopped - there's your answer.
If it is the one you've stopped, the try something like:
netstat -an | grep -i mysql
to see and the some ps -ef and kills (I'm a bit brutal) as required to bring it down.
otherwise, it may not actually using the database to serve the information you want. If information is hard coded in the controllers and view - it'll serve you just fine.

MySQL Installer: Fails at creating user accounts

Currently trying to install and start a MySQL Server on my machine. I'm using the original, actual Installer/Wizard. After filling out all fields, setting a root passwords and also telling to create one user with the password on localhost, the application fails at the step "Creating user accounts".
The log says:
Attempting to Add New MySQL Users Authentication to host 'localhost'
for user 'root' using method 'mysql_native_password' failed with
message: Access denied for user 'root'#'localhost' (using password:
YES) Ended configuration step: Creating user accounts.
Interesting to note, I've done this on a testing device as well as on a fresh virtual machine. I've used different data and names actually, but with the same result >_< What could I be doing principally wrong?
Thanks in advance!
EDIT: Sort of solved... I re-downloaded the database alone and manually created users. Guess that's the better way when being about to learn SQL properly anyways.
That error blocks your installation - although your MySQL server is running - it keeps you from installing the samples and examples. However, if you ignore installing these samples and examples, you can start MySQL Workbench. Moreover, the root account will be available with the password you have set during the install procedure (using Windows). Just launch the Workbench.
I went back to the Accounts and Roles tab> "edit" on my user and my account said I needed a user name> reentered User name> save> next> rename MySQL> Execute== ran fine and finished install.
This was the easy way with all other updates for co-programs done already.
For anyone still having trouble, a simple solution for me was making sure my user names and passwords did not contain special characters such as \ > ~, and so on. Characters such as # and ! should work fine.

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..