What distinguishes a user in MySQL?
1st user:
CREATE USER 'user5'@'';
SET PASSWORD FOR 'user5'@'' = PASSWORD('123457');
2nd user:
CREATE USER 'user5'@'%';
SET PASSWORD FOR 'user5'@'%' = PASSWORD('123456');
You can use the DROP USER statement to drop multiple users by comma separating the users that you wish to drop. For example: DROP USER 'smithj'@'localhost', 'andersonk'@'localhost'; This DROP USER example would drop two users in MySQL - smithj and andersonk.
The MySQL hostname defines the location of your MySQL server and database. If you want to connect to the information in a MySQL database, you'll need to know the hostname. Again, the hostname is usually localhost, which indicates that the database is running on the same server as your application (e.g. WordPress).
If you want to login as a different user on MySQL, you need to use “mysql -u -p command”.
The part after @
specifies a host from which the user being created is allowed to connect. For example, for web applications where Web-server and MySQL server live on the same physical machine, this parameter usually set to localhost
. %
means all hosts, saying that user is allowed to connect from any machine.
Although username@hostname1
and username@hostname2
use same username, they are different users and can have different privileges.
'user5'@'' and 'user5'@'%' is the same. but the user with the host =% has a higher priority to the user with a host =''.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With