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' ..].
##More related free learning recommendations: mysql tutorial(Video)
Mysql login method to create a user:
1. Use the root account to log in to mysqlTo 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 -p2. 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 located3. When logging in to another host, it will Error Command:
本机登陆:mysql -ulcocaluser -p 远程登陆:mysql -h mysql服务器ip -ulocaluser -p4. 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 -pRemote login: mysql -h mysql server ip -ulocaluser -p5 , 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 -pDelete users, will be used in the following scenariosYou cannot create an account with the same name, you must first delete the existing one, and then you can create oneFor safety, delete the one that is no longer used AccountCommand:
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!