Rails mysql can't connect using password yes - mysql

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.

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!

Heroku. MariaDB. Access denied for user

I'm creating new app on Heroku. Installed add-on "JawsDB Maria" successfully - I can open it's dashboard
In PHP on connection to DB I receive error:
SQLSTATE[HY000] [1044] Access denied for user 'vcgu1h273742rn5l'#'%' to database 'jeyx2j66ipgtqe11'
I'm sure that problem is not in PHP, because the same error I receive even on MariaDB dashboard trying to Create New Databite - https://prnt.sc/rj4dr4 .
Looks like solution is to GRANT ALL PRIVILEGES to user. But using dashboard I can't execute even SHOW GRANTS.
Questions:
Can somebody help how to solve this problem?
Or, at least, which way I can GRANT ALL PRIVILEGES?
I've tried:
read Heroku docs: JawsDB MySQL, PHP + DB
searching for similar problems in Heroku support, Google, SO:
the best match I found is here. But heroku pg:psql - it's tool only for PostgreSQL.
tried to find useful command for my case in Heroku CLI Commands
Additional info - I'm sure it is not important, but just in case it is:
project is based on Yii2
for easy deployment on Heroku installed "purrweb/yii2-heroku"
You probably know how to read your error message. At any rate, my superpower is explaining the obvious. So, ... here goes.
SQLSTATE[HY000] [1044] Access denied for user 'vcgu1h273742rn5l'#'%' to database 'jeyx2j66ipgtqe11'
Tells you your php program couldn't get to the MySQL server. That operation goes in these steps.
Make a TCP/IP network connection to the server. SUCCESS.
Present a user name and password to the server. SUCCESS.
But the server rejected those credentials. FAILURE
Access the database schema mentioned in the connect request. Not attempted yet. So we have no information about whether the named database actually exists.
The success of step 1 means there are no firewall or network-routing issues. That's good.
The success of step 2 gives us even more confidence about firewall issues.
The failure of step 3 tells us that we're not using a username and password that the MySQL server knows about.
Step 4 is incomplete. So, even if we fix the username and password issues, we still might get another issue before this mess is behind us.
Heroku assigns those usernames to their customers. So, check on the appropriate Heroku control panel to see whether you're using the right username / password credentials. Your error message says you've got wrong credentials.
Next step? Ask your vendor for help. Is Bruce Schneier is reading this? Maybe he can fix this for you from his earbuds while he's riding on the subway. But none of the rest of us here on SO can fix it.
I've waited for 8 hours, hoping there is some trigger, that will complete all necessary settings. But it didn't helped.
Then I reinstalled this add-on. And now all works fine!
So, that was some kind of "JawsDB Maria" bug.

MySQL root user suddenly not connecting using password

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.

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.

symfony database access configuration problem

I just joined a web dev project that uses Symfony 1.4 on CentOS 5.4 with MySQL. The server is down. My first task in the project is to get it back up. I don't know a lot about Symfony.
The Apache server log says
Access denied for user 'root'#'localhost' (using password: NO)
From all I can tell, the database access configuration is stored in
/var/www/html/<project name>/config/databases.yml
and for some reason, there's also some config in
/var/www/html/<project name>/config/propel.ini
There was no password for user root in either of the files, so I thought adding it and restarting Apache would finx the issue. It does not, the error message stays the same. I might be looking at the wrong config files, but I can't find any other.
Any wild guesses how to fix this ?
Cheers,
ssc
OK, I know now what I did wrong: The password indeed has to be added to databases.yml, but whenever the configuration is changed, the symfony cache needs to be cleared by executing
./symfony cc
in the /var/www/html/<project name>/ folder.
You are right, the database config file is stored at /WEB/project/config/databases.yml
You can also try to run the configure:database command from the symfony command line tool.
php symfony configure:database "mysql:host=DBHOST;dbname=DBNAME" USER PASS
A getting started guide, and much more can be found at: http://www.symfony-project.org/jobeet/1_4/Propel/en/