What does% mean in the host column and how to change the user password

Well, here is what I see:

select host, user from mysql.user; +-----------+------------------+ | host | user | +-----------+------------------+ | % | me | | 127.0.0.1 | root | | ::1 | root | | localhost | | | localhost | debian-sys-maint | | localhost | root | | ubuntu | | | ubuntu | root | +-----------+------------------+ 

I entered as root and would like to change the password for the user 'me'.

 SET PASSWORD FOR 'me'@'%' = PASSWORD('letmein'); Query OK, 0 rows affected (0.00 sec) 

Well, no lines are visible, as we can see.

Regarding the access attempt, the result is as follows:

 Access denied for user 'me'@'localhost' (using password: YES) michael@ubuntu :/var/www/cgi-bin$ 

So he mentions localhost, not%.

Could you suggest me how to change the password for "me" and explain what%?

+4
source share
2 answers

You need to set a password for localhost :

 SET PASSWORD FOR 'me'@'localhost' = PASSWORD('letmein'); FLUSH PRIVILEGES; 

% means that remote hosts can connect to the MySQL server from any other server, while localhost means that you can only enter the MySQL server from the same machine.

+6
source

'%' means that you can enter the database from any host connected to this database. You also define your local host as the host if you want to access the database from the local host.

to change the password:

 SET PASSWORD FOR 'me'@'%' = PASSWORD('letmein'); 

and do not forget to do:

 FLUSH PRIVILEGES; 

to commit changes. See MySql Account Management.

UPDATE:

As in your user table, I did not find the username with host = localhost, you must first create this user ( add the user here):

 Grant all privileges on *.* to me@ 'localhost' identified by 'letmein'; flush privileges; 
0
source

Source: https://habr.com/ru/post/1440262/


All Articles