MySQL Node.js module: Unable to create connection pool. Error: Access denied for user - mysql

I am trying to create a connection pool using:
mysql.createPool(dbConnOptions)
My dbConnOptions object is:
var dbConnOptions = {
host: '192.168.5.11',
port: 3306,
user: 'johnDoe',
connectionLimit: 10,
charset: "utf8mb4",
database: 'myDatabase',
password: 'myPassword',
multipleStatements: true
};
I am on a Ubuntu server with /etc/hostname having an entry set to 'myHostname'
I have created a MySql user as
create user 'johnDoe'#'localhost' identified by 'myPassword';
grant all privileges on myDatabase.* to 'johnDoe'#'localhost';
The following error is reported:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'johnDoe'#'myHostname' (using password: YES)
So I tried the following:
grant all privileges on myDatabase.* to 'johnDoe'#'%';
That was rejected with this error:
ERROR 1133 (42000): Can't find any matching row in the user table
Any suggestion would be greatly appreciated. It has been frustrating.

You have created a user johndoe#localhost but you try to access the db with johndoe#myhost and there is no user johndoe#% so you can't grant any privileges to that user.
johndoe#host1 and johndoe#host2 are two totally different users (eventhough they may share the same username) with different priviledges.
And if you want to use the privileges for #localhost you should use 127.0.0.1 or localhost as host ... Because if you are using a custom hostname or the actual IP address, you are not connecting via the loopback device and thus, are not identified as #localhost

Related

Mysql2::Error::ConnectionError: Access denied for user 'rails_user'#'localhost' (using password: YES)

I get the following error when I run 'rails db:schema:dump' after initially configuring my Ruby on Rails project and checking the schema set-up for my Mysql database, which should be empty in terms of data so far the tables I've created:
Mysql2::Error::ConnectionError: Access denied for user 'rails_user'#'localhost' (using password: YES)
I enter mysql -u root -p in the command line and create the following databases:
CREATE DATABASE simple_ex_development;
CREATE DATABASE simple_ex_test;
Now instead of using root user to connect to my newly created databases (which isn't an optimal security practice), I define a new user that the rails application can use to connect to them called 'rails_user' as follows:
GRANT ALL PRIVILEGES simple_ex_development.* TO 'rails_user'#'localhost' IDENTIFIED BY 'blahpassword'
GRANT ALL PRIVILEGES simple_ex_test.* TO 'rails_user'#'localhost' IDENTIFIED BY 'blahpassword'
Then I exit mysql and go to my rails application config/database.yml file and update the username and password, respectively:
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: rails_user
password: blahpassword
host: localhost
Then when I go back to the terminal and run 'rails db:schema:dump' I get the following error above, when I'm not expecting to get anything at all. I've read other stackoverflow posts here touching on similar issues and hinting that it might be anonymous user.
Why am I getting this error message and how can I resolve it?
Any pointers here would be great, thank you!
P.S. When I do run rails server I can see the web app on localhost but again, I'm not sure if it's being configured properly to the new user and password versus root and my root password.
Try creating the user before granting privileges:
CREATE USER 'rails_user'#'localhost' IDENTIFIED BY 'blahblahpassword';
And then grant the privileges the same way:
GRANT ALL PRIVILEGES ON simple_ex_development.* TO 'rails_user'#'localhost' IDENTIFIED BY 'blahpassword';
GRANT ALL PRIVILEGES ON simple_ex_test.* TO 'rails_user'#'localhost' IDENTIFIED BY 'blahpassword';

Access denied for user 'user1'#'localhost' goddady

does anybody know in which table godaddy store the users table ?
I have a database created using database wizard and I have added a user using the mysql database wizard to the database. But I still get the error;
Connection failed: Access denied for user 'user1'#'localhost' (using password: YES)
I tried this:
GRANT ALL PRIVILEGES ON *.* TO 'user1'#'%'; FLUSH PRIVILEGES;
But I keep getting;
1045 - Access denied for user 'cpses_odldzcvpqv'#'localhost' (using password: YES)
It must have something to do with the USER_PRIVILEGES table in information_shema. when I type
SELECT * FROM `USER_PRIVILEGES`
IS_GRANTABLE is set to NO.
On unix based systems, mysql treats localhost and tcp/ip separately. If you wish to give access to localhost, you must also give an explicit permission to localhost along with %.
GRANT ALL PRIVILEGES ON *.* TO 'user1'#'localhost' identified by '<password>';
or you can connect via 127.0.0.1 instead of localhost. That'll work.
mysql -u user1 -p<password> --host 127.0.0.1

How do I resolve a "warning" that says that it could not connect to the sql server using password:YES?

Warning: mysql_connect(): Access denied for user 'msuparam_17'#'localhost' (using password: YES) in /home/msuparam/public_html/17database/Formfeed/Formreg.php on line 11
Could not connect: Access denied for user 'msuparam_17'#'localhost' (using password: YES)
Access denied for user 'msuparam_17'#'localhost'
Access denied means that you were able to establish a connection to the server, but it has rejected your credentials.
Either you have typed the wrong username, the wrong password, or this user does not actually have privileges to login.
If you can login to the database as an authorized user, verify this user actually exists, and is permitted to login.
mysql -u root -p
Password:
mysql> use mysql;
# Verify user actually exists
mysql> SELECT User,Host FROM user WHERE User="msuparam_17";
# Check permission for user
mysql> SHOW GRANTS FOR 'msuparam_17'#'localhost';

Monitoring : Centreon - How to connect centreon user to database?

I'm running Centreon Entreprise Server (CES) 3.3 and added NagVis (1.8.x). They are on a virtual machine (Virtualbox).
When I suceeded in giving the rights to NagVis to reach my Centreon data, Centreon started displaying : "Database error: Could not connect to database", though the centreon user has all privileges on "centreon" and "centreon_storage".
Here's my central-broker-master.log :
[1467987167] error: storage: rebuilder: could not connect to Centreon Storage database: could not open database: Access denied for user 'centreon'#'localhost' (using password: YES) QMYSQL: Unable to connect
[1467988484] error: TCP: error while sending data to peer 'localhost:5670': The remote host closed the connection
[1467988492] config: module applier: loading directory '/usr/share/centreon/lib/centreon-broker'
[1467988492] config: correlation: invalid correlation configuration, correlation engine is NOT loaded
[1467988492] config: applier: 14 modules loaded
[1467988492] error: could not open database: Access denied for user 'centreon'#'localhost' (using password: YES) QMYSQL: Unable to connect
[1467988492] error: TCP: could not connect to localhost:5670: Connection refused
[1467988492] error: could not open database: Access denied for user 'centreon'#'localhost' (using password: YES) QMYSQL: Unable to connect
(the last error is written hundreds of times ...)
And I couldn't find other errors in different logs. (Or wasn't able to find the right logs ...)
The 'centreon' user has the rights on the databases with the IP address of my server as well as with my coputer's address. (This could have been a matter of rights from a distant location)
I don't know any other way to grant my 'centreon' user with extra rights on the database -- Is it even a valid idea to grant my user with all privileges ?
Thanks
EDIT : I tried to solve the problem by using this post : MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES) (I actually had a ''#'localhost' user), but my access to Centreon web is still denied.

MariaDB setting : Access denied for user 'root'#'ma' (using password: YES)

[update]
I solve the problem by :
SET PASSWORD FOR 'root'#'ma'=PASSWORD('pass');
And I still have a question want to askļ¼š
should I set password for 127.0.0.1 and ::1 ???
What's these two root user is???
[original question]
I have a server
I can log in DB on the server
From my computer,I can access ,too.
BUT WHEN I put the code on tomcat on that server
I run the code and got error : Access denied for user 'root'#'master' (using password: YES)
I guess it's because my code is jdbc:mysql://192.168.xx.xx:3306/project
not jdbc:mysql://127.0.0.1:3306/project
How can I fix this problem?? What should I set ?
It's a question of GRANTs:
For connecting to an IP address or hostname:
GRANT ... TO 'user'#'192.2.3.4' ...;
GRANT ... TO 'user'#'host.name' ...;
For connecting to localhost (alias 127.0.0.1) -- That is, when the client is on the same machine as the server:
GRANT ... TO 'user'#'localhost' ...;
(Actually, you can use either technique to connect from the same server.)