Error ERROR [HY000] [MySQL][ODBC 5.1 Driver]Access denied for user (using password: YES) ERROR [HY000] [MySQL][ODBC 5.1 Driver]Access denied for user (using password: YES)
Must be the semicolon in the password
Make sure that your MySql server allows remote connections. If not you'll have to bind the database and user to the remote IP(s) You also need to check the servers firewall settings to make sure 3306 (or whatever you're using) is allowed and that incoming connections are permitted.
Try this: Connect your database using MySQL Workbench and try to run the following SQL statements:
GRANT ALL PRIVILEGES
ON <database>.*
TO '<user>'#'localhost' IDENTIFIED BY '<password>';
SET PASSWORD
FOR <user>#localhost = PASSWORD('<password>');
If nothing else works, it might be something you mistyped in the password etc. To fix, connect as root, and reset the database permissions, password and flush the privileges:
GRANT ALL PRIVILEGES
ON <database>.*
TO <user>#localhost IDENTIFIED BY '<password>';
SET PASSWORD
FOR <user>#localhost = PASSWORD('<password>');
Flush Priviliges;
Related
I am currently trying to run a service using ruby on rails, while running the command rake db:schema:load
I got a password not provided error, checking my database.yml file I found this line:
#password:
I removed the comment but got the same error so I actually specified a dummy password like so:
password: dummy
Then I got this error
password authentication failed for user "ivan"
After this I tried this solution to actually set my password as dummy I still get the same error, my pg_hba.conf has the following line:
local all all peer
Changing peer to md5 produces the same error, after checking my postgres roles the only one listed is "postgres" not "ivan", what is the cause of this role appearing when trying to run my command and how do I fix it?
You need to create new user in postgres . please try below commands for creating new role and user
sudo su postgres
psql
du # for checking all existing roles
CREATE ROLE ivan WITH LOGIN SUPERUSER PASSWORD 'ivan123';
du # check whether this role created or not
then add database user name as 'ivan' and password as 'ivan123' in your database.yml
OK SO land, I have exhausted all attempts to find an answer for my issue.
I have a RoR app running Mongoid 3.16 and a remote server with Mongodb 3.05. Both servers are on the same network and I am using internal IP address to connect.
The problem that I am having is trying to secure the connection. First off, if I try to add the app IP to the bind_ip in the mongod.conf file I get an error:
Cannot assign requested address for socket: app_ip_address
Here is the bind_ip in the mongod.conf:
#bind_ip=127.0.0.1,app_ip_address
If I uncomment it and try to restart mongodb it gives me the error about "Cannot assign requested address..." So I can connect from the app to mongodb IF I leave the bind_ip commented out. I do not like this idea because it will allow any connection.
My mongoid.yml file is:
production:
sessions:
default:
database: my_database
hosts:
- mongodb_server_ip:27017
I also set up the database to have a user but if I set the auth to true for Mongodb, it will allow connection to the "my_database" without authorization, but cannot read the data unless I authenticate again (which I can do command line but not via the mongoid.yml file)
For example if I connect command line from the app server with:
mongo mongoddb_server_ip:27017/my_database
That works but when I try to view collections I have to db.auth(....) to see them.
I guess that if I can config the mongoid.yml with the username/password for mongodb that would work but I cannot figure out how to do that.
Update 11/23:
OK, I set the mongod.conf file to auth = true. Now I can connect from the app server via ssh:
mongo mnogodb_server_ip:27017/my_database --username some_username --password some_password
That allows me to connect and access all collections etc. Now that I am requiring authentication I updated my mongoid.yml file as so:
production:
sessions:
default:
database: my_database
username: some_username
password: some_password
hosts:
- mongodb_server_ip:27017
I restart the server and I cannot connect to the remote db.
Well, after all of this I find out that moped 2 does not support authentication for MongoDB 3+.
see here:
Rails Mongoid fails to authenticate - failed with error 13: "not authorized for query on my_db.my_collection"
I am using Rubymine to connect to an Heroku hosted Postgres DB.
I was able to connect a few weeks ago, but now I am getting this error whenever I try to connect:
'The specified user/password combination is rejected:
FATAL: password authentication failed for user "X3v...'
My Heroku DB URL is:
postgres://<password>:X3vuEswiMHjkADaeI5RQvY4WI4#ec2-23-21-170-57.compute-1.amazonaws.com:5432/de8u1hq5ipli85
I am using JDBC to connect. In the "Data Source Properties" dialog box the (partial) URL is:
jdbc:postgresql://ec2-23-21-170-57.compute-1.amazonaws.com:5432/
And I have added my username and password to the User and Password fields.
In the advanced tab I have added
ssl = true
sslfactory = org.postgresql.ssl.NonValidatingFactory
I'm not sure what I have missed.
I understand this is not a solution, but it's works for me:
Take away the current connections to databases.
Driver Rollback and its settings to default.
sudo service postgresql restart
Now again connect.
I guess, but not sure, system uses same driver for the various editors (Idea, DataGrip, pgadmin3). It's setting a bottleneck.
If you have better solution, please write it here.
I'm not sure if this is still relevant, but you misinterpreted URL
In URL schema first gous user, then password
<protocol>://[<user>[:<password]#]<host>[:<port>]/...
so you mixed username with password
When I execute heroku db:pull it finds my local dev db at:
postgres://127.0.0.1/myapp_development?encoding=utf8
once I confirm though, it fails with:
Sequel::DatabaseConnectionError -> PGError: fe_sendauth: no password supplied
I tried running the pull with the local db specified, e.g.
heroku db:pull postgres://root:#localhost/db_name
which gives the same no password supplied error.
I thought I may need to change root: to myname: because thats the user I granted superuser rights to when I setup postgres but neither root: or myname: works
My database.yml has username: and password: blank for all databases specified.
From the command line as myname#ubuntu I can type psql myapp_development and connect fine and run selects.
What am I missing here?
Is it related to my pg_hba.conf settings? I had a look inside that and it says:
# Database administrative login by UNIX sockets
local all postgres ident
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
Should 'trusted' be used there? And if so if I edit that file do I need to restart postgres? And if 'trust' is necessary then how come rails and the psql command line tools work without passwords when logged in as my myname user?
Thank you!
Authentication method trust might do the trick, but as you are undoubtedly aware, this is not secure.
After editing pg_hba.conf, you don't have to restart. A reload is enough (quoting the manual):
The pg_hba.conf file is read on start-up and when the main server
process receives a SIGHUP signal. If you edit the file on an active
system, you will need to signal the postmaster (using pg_ctl reload or
kill -HUP) to make it re-read the file.
pg_ctl reload
See the fine manual. You might need the manual for version for 8.3. Shared db on heroku currently runs on PostgreSQL 8.3. (Also, I doubt you have access to pg_ctl on heroku.)
Be aware of this:
If no password has been set up for a user, the stored password is null
and password authentication will always fail for that user.
Emphasis mine. You might be able to log in locally, because the auth-methods ident or peer allow for that. But for your purpose you may need a password!
Starting to develop my first Ruby on Rails app with postgresql on Ubuntu. I have created a postgresql user with a password. In the database.yml, I put in the postgresql username and password.
Whenever I run a rake db:migrate it executes without error no matter what I change the password to in the database.yml - even if the password field is blank. If I change the username I get an authentication error.
How do I get Ruby on Rails database to use a password?
TIA
You're probably using ident or even trust authentication. A quick synopsis of the most common authentication methods:
trust - You can log in no matter what.
ident - You can log in if your UNIX username is the same as the PostgreSQL username.
md5 - You can log in if your password (encrypted with md5) is correct.
Edit: PostgreSQL 9.0 introduced the peer authentication method. From what I gather, ident and peer have the same purpose—your login is determined by your operating system username—but ident talks to an ident server listening on port 113, while peer looks up your credentials with a system call. See http://www.postgresql.org/docs/9.1/static/auth-methods.html#AUTH-IDENT
Locate your pg_hba.conf file, and see if you can find something that looks like this:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
When you try to connect, PostgreSQL goes through this line-by-line. If the connection type (e.g. local, host), database, user (database user, not system user), and address all match up, it will use the given authentication method.
If you want to require a password to access your own PostgreSQL user, you could add a line like this at the top, before the local all all ident line:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
local mydbname myusername md5
Be sure to restart PostgreSQL after changing pg_hba.conf.
I've only barely used PostgreSQL, but I do know it has a feature called sameuser. If the name of the system user matches the name of the database user, the password is not required. So, if I logged into this computer with the username "matchu", and there is a user in PostgreSQL named "matchu", I could log in to that database user without additional authentication.
Could that be what's going on here?