Home  >  Article  >  Database  >  How to log in to the created user in mysql

How to log in to the created user in mysql

coldplay.xixi
coldplay.xixiOriginal
2020-10-20 11:42:0112458browse

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

How to log in to the created user in mysql

##More related free learning recommendations: mysql tutorial(Video)

Mysql login method to create a user:

1. Use the root account to log in to mysql

To To create an account, you have to contact mysql and enter it. In Linux and mysql, it can be considered that the root user is the emperor of their respective systems and has the power of life and death over other users' data.

Command:

mysql -uroot -p

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

command:

create user '用户名'@'localhost' identified by '用户的密码';

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

3. When logging in to another host, it will Error

Command:

本机登陆:mysql -ulcocaluser -p
远程登陆:mysql -h mysql服务器ip -ulocaluser -p

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

limituser can only be used on the specified host.

Command:

create user 'limituser'@'远程主机ip' identified by '123';

Local login: mysql -ulcocaluser -p

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

5 , create a user who can log in locally and remotely, here is unlimiteduser.

Yes, when creating a user, host uses the wildcard %

command:

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

unlimituser user server host and remote host login

Command:

本机登陆:mysql -uunlimituser -p
远程登陆:mysql -h mysql服务器ip -uunlimituser -p

Delete users, will be used in the following scenarios

You cannot create an account with the same name, you must first delete the existing one, and then you can create one

For safety, delete the one that is no longer used Account

Command:

drop user 'mysqluser'@'host'

Tips:

Mysql user’s host is already %, and you can’t log in remotely, check the firewall.

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

The above is the detailed content of How to log in to the created user in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn