msql password chancing_sha2_password plugin - mysql

I can change the password of root#localhost user from auth_socket ==> mysql_native_password, but other users can not change to mysql_native_password;
mysql.session, mysql.sys, debian-sys-maint and phpmyadmin (when I installed phpmyadmin mysql said: ERROR 1819 (HY000) at line 1 error so I couldn't create a record in the database)
I want all users to be able to change mysql_native_password from chancing_sha2_password plugin because; if I can't change plugin methods; I can't use phpmyadmin or other 3 party app.
(mysql said:ERROR 1819(HY000) at line 1)
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *91EA82EFAD0677E20FDAEC7F11E15244530996F6 | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | caching_sha2_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | caching_sha2_password | localhost |
| debian-sys-maint | *70B3E55DA437B329F2F1A90C66719B666CBF4B9E | caching_sha2_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

i fixed!!!
firstly;install phpmyadmin and add to apache2 and login mysql password.
On the phpmyadmin screen, the mysql password will give an error, but accept the statement and complete the setup. Then type the following code in the mysql command window!
so far
ALTER USER 'phpmyadmin'#'localhost' IDENTIFIED WITH mysql_native_password BY 'TestPassword123*-';

Related

Access denied for user 'admin'#'MY-IP' (using password: YES) when connecting to MySql RDS in AWS

I am able to connect through the below command and see the databases. But unable to run migration or create tables which results in below error.
Command
mysql -h endpoint.rds.amazonaws.com -u admin -p
Error
SQLSTATE[HY000] [1045] Access denied for user 'admin'#'MY-IP' (using password: YES)
(SQL: select * from information_schema.tables
where table_schema = storydb and table_name = migrations and
table_type = 'BASE TABLE')
Queries from MySql command line
show databases;
+--------------------+
| Database |
+--------------------+
| storydb |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
select user, host, plugin from mysql.user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| admin | % | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| rdsadmin | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
Configuration
For those using SSL - RDS (check configuration -> Encryption (enabled)
You need to generate a token as the password (even with auth IAM role)
Get the bundle and then try to connect mysql -h mysqldb.abcd.us-west-2.rds.amazonaws.com --ssl-ca=global-bundle.pem -P 3306 -u myuser --password=$TOKEN
More info on how to generate the token and the bundles : https://aws.amazon.com/premiumsupport/knowledge-center/rds-mysql-access-denied/

How to resolve ERROR 1396 (HY000): Operation ALTER USER failed for 'root'#'localhost'?

I can't login with root ,I think root's password may be changed.But I can't change root's password either.
Mysql version is v8.0.16.
I have used --init-file to specificd alter sql at mysqld booting
alter user 'root'#'localhost' identified by 'mynewpassword'
but it doesn't work.
I used --skip-grant-tables --user=mysql so I could add a new user, and my new user works. I try to alter root,but it failed again.
mysql> alter user 'root'#'localhost' identified by 'mynewpassword';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'#'localhost'
here is the table user's content
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| admin | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
Do anyone have any idea?
You Can try:
ALTER USER 'root'#'%' IDENTIFIED WITH mysql_native_password BY '123';
rather than
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '123';
When you use the following command
mysql> use mysql;
mysql> select user,host from user;
you can find that root's host is '%'
mysql> select user, host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
According to the mysql docs and this one - check the special --init-file option.
And then try to FLUSH PRIVILEGES;
Also, please see this related post.
This should help.

OperationalError: (1698, "Access denied for user 'cotequotey'#'localhost'")

Even after trying the methods in this threadERROR 1698 (28000): Access denied for user 'superuser1'#'localhost', I still have the same error with my username 'cotequotey' which reads:
OperationalError: (1045, "Access denied for user 'cotequotey'#'localhost' (using password: NO)")
And this username 'cotequotey' is the one that I have attributed the auth_socket plugin to, in order for that username to be the default instead of root. So this is what my user table looks like:
mysql> select User,host,plugin, authentication_string from mysql.user;
+------------------+-----------+-----------------------+-------------------------------------------+
| User | host | plugin | authentication_string |
+------------------+-----------+-----------------------+-------------------------------------------+
| root | localhost | mysql_native_password | *B845F78DCA29B8AE945AB9CFFAC24A9D17EB5063 |
| mysql.session | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys | localhost | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| debian-sys-maint | localhost | mysql_native_password | *0C8DDC30A93F5F8834121C4DF8703A051E215166 |
| cotequotey | localhost | auth_socket | |
+------------------+-----------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)
Therefore, I expected my connection via 'cotequotey' to work without a password when I did the command:
ubuntu:~/environment/RAD_Final (angela) $ mysql -u cotequotey
ERROR 1045 (28000): Access denied for user 'cotequotey'#'localhost'
However, this command in the console still produces the original error, so I'm wondering if anyone knows of a solution?
I'm wondering if it is a grant permissions issue, since my root grants permissions are the same as those for cotequotey#localhost.
Wasn't sure if this made them clash.
+---------------------------------------------------------------------+
| Grants for root#localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
+---------------------------------------------------------------------------+
| Grants for cotequotey#localhost |
+---------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'cotequotey'#'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''#'' TO 'cotequotey'#'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------------+
According to the docs:
The socket plugin checks whether the socket user name (the operating system user name) matches the MySQL user name specified by the client program to the server. If the names do not match, the plugin checks whether the socket user name matches the name specified in the authentication_string column of the mysql.user system table row. If a match is found, the plugin permits the connection. The authentication_string value can be specified using an IDENTIFIED ...AS clause with CREATE USER or ALTER USER.
It looks like your mysql account name doesn't match your UNIX user name, and you don't have an alternate specified in the authentication_string field.
ADDENDUM:
Essentially auth_socket says "if the operating system authenticated you, MySQL will trust you too." The default to accomplish that is to check if the Linux account name and the MySQL account name match (so no one else can log into the machine and gain privileges by claiming to be you). You can override this behavior by specifying an alternate name as explained in the documentation linked above.

Grafana with MySQL: this authentication plugin is not supported

I am trying to load some data from MySQL to Grafana, but got the following error. Any idea what I missed? Thanks!
Its happends couse grafana don't maintain the new mysql authorization method named caching_sha2_password. Sinse mysql 8 its default setting.
To solve this problem you need just to create new user with mysql_native_password authentication plugin connector.
Step 1. Check the available users and its plugins.
MySQL [localhost+ ssl] SQL> select user, plugin from mysql.user;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| pi | caching_sha2_password |
| mysql.infoschema | caching_sha2_password |
| mysql.session | caching_sha2_password |
| mysql.sys | caching_sha2_password |
| root | caching_sha2_password |
+------------------+-----------------------+
6 rows in set (0.0011 sec)
All the users has caching_sha2_password authorization plugin.
Step 2. Open the mysql workbench and connect to database.
Execute the query
CREATE USER 'native_user'#'localhost' IDENTIFIED WITH mysql_native_password;
The result must be like this one
09:30:17 CREATE USER 'native_user'#'localhost' IDENTIFIED WITH mysql_native_password 0 row(s) affected 0.156 sec
Step 3. In mysql workbench open server -> users and privilegas
Select native_user form the list. Change the password, default shema and shema privilegas for this user. Save the changes.
Step 4. Check with mysql shell
MySQL [localhost+ ssl] SQL> select user, plugin from mysql.user ;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| pi | caching_sha2_password |
| mysql.infoschema | caching_sha2_password |
| mysql.session | caching_sha2_password |
| mysql.sys | caching_sha2_password |
| native_user | mysql_native_password |
| root | caching_sha2_password |
+------------------+-----------------------+
6 rows in set (0.0011 sec)
Step 5. Open the grafana datasouces and set up new user.
Good luck!
P.S. I cant create a new user with mysql_native_password using mysql workbanch. Maybe its bug. Use command prompt instead.
Thanks. Below works as well. No need to create a new user.
select user,plugin from mysql.user;
alter user root#'localhost' identified with mysql_native_password by 'my_password';
select user,plugin from mysql.user;

Delete user in MySQL is not working

I am a new to MySQL, and I have created a user called magento as described in the table below. Now I am not able to delete that user!
mysql> SELECT User, Host, Password FROM mysql.user;
+------------------+-------------------+-------------------------------------------+
| User | Host | Password |
+------------------+-------------------+-------------------------------------------+
| root | localhost | *F4F8C81F12A316D6884269A228966F1E5763E16F |
| root | mgaber-virtualbox | *F4F8C81F12A316D6884269A228966F1E5763E16F |
| root | 127.0.0.1 | *F4F8C81F12A316D6884269A228966F1E5763E16F |
| root | ::1 | *F4F8C81F12A316D6884269A228966F1E5763E16F |
| debian-sys-maint | localhost | *63EDFEF710866BF1C20505D01DCEFBAA246750BC |
| ‘magento’ | ’localhost’ | |
+------------------+-------------------+-------------------------------------------+
I have used the below commands.
mysql> drop user ‘magento’;
ERROR 1396 (HY000): Operation DROP USER failed for '‘magento’'#'%'
mysql> drop user ‘magento’#'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for '‘magento’'#'localhost'
Both are not working.
How can I fix this problem?
Change this
mysql> drop user ‘magento’;
to
drop user 'magento'#'localhost';
You have to use the right quotes ' and not ‘.
Or use this:
DELETE FROM users where user = 'magento'
check this