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
Related
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*-';
I'm running mariadb-server v10.2.33-1 on two openwrt-qemu systems. I want a remote user to achieve LOCK TABLE on a particular table.
In the local mysql server, I have created a remote user and granted LOCK TABLES privilege using the following commands:
CREATE USER 'root'#'192.168.%' IDENTIFIED BY 'root';
GRANT SELECT ON `qkd`.`RawKeyStatus` TO 'root'#'192.168.%';
GRANT LOCK TABLES ON `qkd`.* TO 'root'#'192.168.%';
FLUSH PRIVILEGES;
Upon running SHOW GRANTS in the remote user system, I can notice the LOCK TABLES privilege has been assigned to 'root'#'192.168.%'. The remote user also has SELECT privilege on the table qkd.RawKeyStatus.
However LOCK TABLE qkd.RawKeyStatus READ; command in the remote system fails with the error:
ERROR 1044 (42000): Access denied for user 'root'#'192.168.%' to database 'qkd'
What am I missing ?
Run SHOW PROCESSLIST; nd see from which System the remote user is login and change the GRANT if it not 192.168,%
MariaDB [(none)]> show processlist;
+------+-------------+-----------+------+---------+------+--------------------------+------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+------+-------------+-----------+------+---------+------+--------------------------+------------------+----------+
| 1 | system user | | NULL | Daemon | NULL | InnoDB purge coordinator | NULL | 0.000 |
| 2 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 3 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 4 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 5 | system user | | NULL | Daemon | NULL | InnoDB shutdown handler | NULL | 0.000 |
| 3357 | root | localhost | NULL | Query | 0 | init | show processlist | 0.000 |
+------+-------------+-----------+------+---------+------+--------------------------+------------------+----------+
6 rows in set (0.01 sec)
MariaDB [(none)]>
UPDATE:
The issue was related to the wildcard 192.168.%. In order to give GRANT to all users of the subnet 192.168.A.B a correct wildcard would be 192.168.%.%
A more safer option is to use a subnet mask:
GRANT ... TO 'user'#'192.168.0.0/255.255.255.0' IDENTIFIED BY ...
Now LOCK TABLE qkd.RawKeyStatus READ; command runs perfectly with the output
Query OK, 0 rows affected (0.02 sec)
Reference: How to grant remote access to MySQL for a whole subnet?
A quick workaround is to pass the –-single-transaction option to mysqldump:
for example:
$ mysqldump --single-transaction -u user -p DBNAME > backup.sql
ref: https://michaelrigart.be/mysqldump-1044-access-denied-using-lock-tables/
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.
I'm running MySQL Ver 15.1 Distrib 10.3.9-MariaDB for OSX10.13 and have a bunch of users (around 14) where the username is apparently too long, see below.
MariaDB [(none)]> SELECT Host, User FROM mysql.user;
+-----------+-------------------------+
| Host | User |
+-----------+-------------------------+
| 127.0.0.1 | tenant_2SxSBywyXh3QW5L4 |
| 127.0.0.1 | tenant_4j3CWVXjgtDD2OrI |
| 127.0.0.1 | tenant_5OOBxRgjSvFehwI2 |
| 127.0.0.1 | tenant_6C3vAqBTVns8rMTT |
| 127.0.0.1 | tenant_9PVCY1Msa61u43Oh |
| 127.0.0.1 | tenant_RyFspluIGEi3Fkby |
| 127.0.0.1 | tenant_SQtfEQZmWRFfKmHy |
| 127.0.0.1 | tenant_VC8pYaJ3it1LdYK3 |
| 127.0.0.1 | tenant_Zr84h3vkLdwkqR33 |
| 127.0.0.1 | tenant_cvifD1I2Rjghjnpu |
| 127.0.0.1 | tenant_jO1tUJJokremTW5P |
| 127.0.0.1 | tenant_p6Bhzhi0OqMH4gc9 |
| 127.0.0.1 | tenant_rjyOX1NqEN6k6mk4 |
| 127.0.0.1 | tenant_xfcHjsn0mHBfURAw |
| 127.0.0.1 | test_testing_local |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+-------------------------+
18 rows in set (0.000 sec)
When I try to drop these users using the following command I'm in encountering this error:
MariaDB [(none)]> DROP USER 'tenant_5OOBxRgjSvFehwI2#127.0.0.1';
ERROR 1470 (HY000): String 'tenant_5OOBxRgjSvFehwI2#127.0.0.1' is too long for user name (should be no longer than 32)
MariaDB [(none)]> DROP USER 'tenant_5OOBxRgjSvFehwI2#localhost';
ERROR 1470 (HY000): String 'tenant_5OOBxRgjSvFehwI2#localhost' is too long for user name (should be no longer than 32)
Any idea's on how I can drop these users?
Most annoying side effect of this is when opening up SequalPro, and I get 14 errors (one after the other) notifying me of this user name being too long issue.
Also, another odd question that I'd be interested to hear about is why when these user name are only 22-24 characters long are they causing a ... too long for user name (should be no longer than 32) error, as they don't breach the 32 character limit?
Appreciate any help :)
You can try several options. Can try the latest test build of SequelPro. The test build (3477d22) seems to solve the long names issue for me.
Test Builds are here: https://sequelpro.com/test-builds
Or one of the latest development builds. http://nightly.sequelpro.com/
For me, with Mariadb 10.x server and nightly build, it also worked for me.
You have to comment the 'username' # 'host' ...
Use:
DROP USER 'tenant_5OOBxRgjSvFehwI2'#'127.0.0.1';
I can't reproduce the problem:
MariaDB [(none)]> SELECT VERSION();
+-----------------+
| VERSION() |
+-----------------+
| 10.3.11-MariaDB |
+-----------------+
1 row in set (0.000 sec)
MariaDB [(none)]> DESC mysql.user; -- User char(80)
+------------------------+-----------------------------------+------+-----+----------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+----------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(80) | NO | PRI | | |
.
.
.
+------------------------+-----------------------------------+------+-----+----------+-------+
47 rows in set (0.001 sec)
MariaDB [(none)]> CREATE USER 'tenant_5OOBxRgjSvFehwI2'#'127.0.0.1';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> DROP USER 'tenant_5OOBxRgjSvFehwI2#127.0.0.1';
ERROR 1396 (HY000): Operation DROP USER failed for 'tenant_5OOBxRgjSvFehwI2#127.0.0.1'#'%'
MariaDB [(none)]> DROP USER 'tenant_5OOBxRgjSvFehwI2I'#'127.0.0.1'; -- Wrong user
ERROR 1396 (HY000): Operation DROP USER failed for 'tenant_5OOBxRgjSvFehwI2I'#'127.0.0.1'
MariaDB [(none)]> DROP USER 'tenant_5OOBxRgjSvFehwI2'#'127.0.0.1';
Query OK, 0 rows affected (0.001 sec)
I mistakenly created a user that I now am unable to delete. Following is the code snippet interacting with MySQL:
mysql> DROP User 'netbeansuser'#'%';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'#'%'
mysql> select User from mysql.user;
+------------------+
| User |
+------------------+
| root |
| root |
| debian-sys-maint |
| netbeansuser |
| root |
| root |
+------------------+
6 rows in set (0.00 sec)
mysql> DROP User 'netbeansuser';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'#'%'
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> select User from mysql.user;
+------------------+
| User |
+------------------+
| root |
| root |
| debian-sys-maint |
| netbeansuser |
| root |
| root |
+------------------+
6 rows in set (0.00 sec)
mysql> DROP User 'netbeansuser';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'#'%'
mysql> DROP User 'netbeansuser'#'%';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'#'%'
What am I doing wrong? Particularly, what is the '%' sign at the hostname for? I didn't specify the hostname while creating the user. Any resources on understanding hostname bindings in MySQL USER creation will also help. Thanks all.
This will be helpful.
Use 'localhost' instead of '%'.