I have a 2 nodes mariadb cluster with one maxscale load balancer.
maxscale blocks connection if i want to connect directly to a database: so for example:
mysql -h 35.300.208.100 -u finn -p works and if i then do a USE test i can do everything with the database "test". so the rights are correct.
but if a do a mysql -h 35.300.208.100 -u finn -p test i get the error:
ERROR 1045 (28000): Access denied for user 'finn'#'188.68.43.150' (using password: YES) to database 'test'
So if i do the same on the nodes with localhost, everything works fine.
This is my maxscale.cnf
Most of the time you will receive ERROR 1045 (28000): Access denied when the grants on the database do not contain matching grants for both the client IP and the MaxScale IP.
The usual way of solving this is to:
Execute SHOW GRANTS on the database from the client server
Execute SHOW GRANTS on the database from the MaxScale server
Compare the output of the two queries and make sure they are identical
This is usually enough to spot any problems with grants in the database.
Another way to resolve these sorts of errors is to execute the query that MaxScale uses to load the database users. The exact SQL for these queries can be found on the MaxScale wiki on GitHub. For MaxScale 2.1 and newer, this would be:
SELECT u.user, u.host, d.db, u.select_priv, u.password
FROM mysql.user AS u LEFT JOIN mysql.db AS d
ON (u.user = d.user AND u.host = d.host)
UNION
SELECT u.user, u.host, t.db, u.select_priv, u.password
FROM mysql.user AS u LEFT JOIN mysql.tables_priv AS t
ON (u.user = t.user AND u.host = t.host);
This should return a result set containing the authentication data that MaxScale uses. Here's an example of what the query can return:
+---------------+-----------+------+-------------+-------------------------------------------+
| user | host | db | select_priv | password |
+---------------+-----------+------+-------------+-------------------------------------------+
| root | localhost | NULL | Y | |
| maxuser | 127.0.0.1 | NULL | Y | *5EDBD32E469DAE0CE10E6999C3899DEFCB9F12E0 |
| root | % | NULL | Y | |
| maxuser | % | NULL | Y | *5EDBD32E469DAE0CE10E6999C3899DEFCB9F12E0 |
| skysql | 127.0.0.1 | NULL | Y | *85058F5DEAD82AE3507664C2C11BDA7B1827B80D |
| skysql | % | NULL | Y | *85058F5DEAD82AE3507664C2C11BDA7B1827B80D |
| test | % | NULL | Y | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |
| stackoverflow | % | test | N | *5635C63172887A7D7C0828876228A5E4DC523969 |
| stackoverflow | % | NULL | N | *5635C63172887A7D7C0828876228A5E4DC523969 |
+---------------+-----------+------+-------------+-------------------------------------------+
The select_priv tells whether the user is allowed to connect with any default database. If it is set to N, then the value in the db column is the only database that the client is allowed to use. As we can see from the example result, the 'stackoverflow'#'%' user is either allowed to connect without a default database or with the test default database.
Related
I just create mysql 8.0.20 server on AWS RDS.
I'm try to change global varible.. on workbench or via the terminal..
and get this msg
Error Code: 1227. Access denied; you need (at least one of) the SUPER or SYSTEM_VARIABLES_ADMIN privilege(s) for this operation
but I have only one master user..
mysql> SELECT user, host FROM mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| admin | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| rdsadmin | localhost |
+------------------+-----------+
5 rows in set (0.16 sec)
I'm confused and don't understand who is the master.. (according to aws is admin)
I want to understand with which user I can add another or run some simple script like
SET GLOBAL innodb_lock_wait_timeout = 5000;
When I create a user in mysql, following this:
CREATE USER IF NOT EXISTS 'devadmin'#'localhost' IDENTIFIED BY 'admindev';
GRANT ALL PRIVILEGES ON developerparse.* TO 'devadmin'#'%';
FLUSH PRIVILEGES;
I can join into mysql:
mysql -u devadmin -p
but I need set remote access for user, so when I set the host to '%':
CREATE USER IF NOT EXISTS 'devadmin'#'%' IDENTIFIED BY 'admindev';
and trying to join mysql, I get an error:
MySQL ERROR 1045 (28000): Access denied for user 'devadmin'#'localhost' (using password: YES)
How to resolved that?
table of users accounts:
select user, host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| devadmin | % |
| devuser | % |
| prodadmin | % |
| produser | % |
| testadmin | % |
| testuser | % |
| debian-sys-maint | localhost |
| developer | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
% mean this user can be from any host. localhost, the user can only from that server. This can be usefull for root by example (security purpose). root#localhost mean nobody can connect with root user, except from the server itself.
I setup my website on AWS.
Now, the problem is: I am able to select data from my DB but I am not able to insert it. But, my root is having "Insert" privileges.
I did create another user and provided the same privileges but the same problem persists.
Here is my configuration:
mysql - "select" and "insert" privileges for "root" user.
+-------------+-------------+
| Select_priv | Insert_priv |
| Y | Y |
+-------------+-------------+
mysql - "host" and "user" details
+----------------+------+
| host | user |
| % | root |
| 127.0.0.1 | root |
| (my ip) | root |
| ::1 | root |
| ip-(my ip) | |
| ip-(my ip) | root |
| localhost | |
| localhost | root |
+----------------+------+
php - I am connecting using "username" as "root", "host" as "localhost" and "port" as 3306
Inbound security group
Outbound security group
Table names in insert query are case sensitive when deployed in aws RDS mysql. So, make sure to have same table names i.e. same case in insert query and in database. I hope this will work.
The error is 1045. But my username and password are correct.
I am connecting as fcapdi from 192.168.0.18 (to 192.168.0.240:3306)
My users table
MariaDB [(none)]> SELECT User,Host FROM mysql.user;
+--------+-----------+
| User | Host |
+--------+-----------+
| dba | % |
| fcapdi | % |
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | tester |
| root | tester |
+--------+-----------+
When I login with phpMyAdmin with the root account I receive
#1045 - Access denied for user 'root'#'localhost' (using password: YES)
But my account dba can login fine. What is going on?
Also I guess I should note the MySQL instance is sitting on a server that has 2 NIC's and sits on 2 (internal) networks. One is a local domain 192.168.0/24 the other is a larger domain 10.228./16.
I can login via the fcapdi account from the 10.228./16 network. But not from the 192.168.0./24 network.
Execute:
GRANT ALL ON
your_database_schema_name.* to
'fcapdi'#'192.168.0.18' IDENTIFIED BY 'your_connection_password';
as user with GRANT privileges on the server and try to connect.
As an aside question under comments
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('newPass123^');
SET PASSWORD FOR 'root'#'127.0.0.1' = PASSWORD('newPass123^');
SET PASSWORD FOR 'root'#'etc_etc' = PASSWORD('newPass123^');
you can also do it in a single update statement but it depends on your mysql version
create user 'joe1'#'localhost' identified by 'blah';
create user 'joe1'#'127.0.0.1' identified by 'afadfafsdblah2';
create user 'joe1'#'%' identified by 'djdjdjjdjdd';;
select user,host,password from mysql.user where user='joe1';
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| joe1 | localhost | *0380BEA27363E56C37F0BFDA438F429080848051 |
| joe1 | % | *7BEAF25E9BDFBDEF5A9B9E4A37023721B668FA51 |
| joe1 | 127.0.0.1 | *5CD978E569B31B1558E5C1D0972E6E02516893BF |
+------+-----------+-------------------------------------------+
update mysql.user set password=PASSWORD('nEW_COMMon_password762') where user='joe1';
-- 3 rows updated
select user,host,password from mysql.user where user='joe1';
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| joe1 | localhost | *A248B352CE5BF750A11AA9BA253B5F191C721D1A |
| joe1 | % | *A248B352CE5BF750A11AA9BA253B5F191C721D1A |
| joe1 | 127.0.0.1 | *A248B352CE5BF750A11AA9BA253B5F191C721D1A |
+------+-----------+-------------------------------------------+
For Mysql 5.7 it is not a column named password. Instead do it against authentication_string
Cleanup:
drop user 'joe1'#'%';
drop user 'joe1'#'127.0.0.1';
drop user 'joe1'#'localhost';
Hi so I am trying to set up my mysql server to accept remote connections from all hostnames by using a % sign in the place of hostname. This however still will not let me connect. My MySQL user table is as follows:
mysql> select host,user from user;
+----------------+------------------+
| host | user |
+----------------+------------------+
| % | guest |
| 127.0.0.1 | root |
| 197.87.180.*** | guest |
| ::1 | root |
| localhost | |
| localhost | debian-sys-maint |
| localhost | root |
| raspberrypi | |
| raspberrypi | root |
+----------------+------------------+
I am able to connect to the server using the username guest from my remote computer with IP address 197.87.180.* but any other IP it gives me the error Access denied for user 'guest'#'197.87..' (using password: YES)
Anyone know the reason for this or what I am doing wrong?
Verify the privileges for guest#'%' with the following:
show grants for 'guest'#'%';
Also, user guest can have a different password for host 197.87.180.*** and another password for host %.
You can verify if the password is the same for both instances of guest user by executing the following query: select host,user,password from mysql.user;
If they don't have the same password, you can change it by executing the following: set password for guest#'%' = password('newPwd');
Cheers,
JF