Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of creating users by mysql login

2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces mysql login to create user methods, the text is very detailed, has a certain reference value, interested friends must read!

mysql login Create user method: 1. Log in to mysql using root account, code is [mysql -uroot -p];2. Create a user that can only be used on the host where mysql server is located, code is [create user 'username'@'localhost'..].

mysql login Create user:

1. Log in to mysql using the root account

To create an account, you have to contact mysql and enter it. In Linux and mysql, you can think of the root user as the emperor of their respective systems and have the power to kill other users 'data.

Command:

mysql -uroot -p

2. Create a user that can only be used on the host where the mysql server is located, here localuser

Command:

create user 'username'@'localhost' identified by 'user's password';

localuser can be used normally on the host where mysql server is located

3. When another host logs in, it will report an error

Command:

Local login: mysql -ulcocaluser-p Remote login: mysql -h mysql server ip-ulocaluser-p

Create an account that can only be used by a specific remote host, here limituser.

limituser can only be used on specified hosts.

Command:

create user 'limituser'@'remote host ip' identified by '123';

Local login: mysql -ulcocaluser -p

Remote login: mysql -h mysql server ip-ulocaluser-p

Create a user who can log in locally and remotely, here unlimituser.

Yes, that is, when creating users, host uses wildcards %

Command:

create user 'unlimituser'@'%' identified by '123';

unlimituser user server host and remote host login

Command:

Local login: mysql -uunlimituser -p Remote login: mysql -h mysql Server ip-uunlimituser-p

Delete user, which is used in the following scenarios

You cannot create an account with the same name. You must delete an existing account before you can create it.

For security reasons, delete accounts that are no longer in use

Command:

drop user 'mysqluser'@'host'

Small note:

mysql user's host is already %, can not log in remotely, go to see firewall oh.

If the remote host cannot access port 3306 (the default listening port of mysql server), it is impossible to log in to the remote mysql server.

The above is mysql login to create all the content of the user method, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report