Some basic commands:
Login:
Mysql-u username-p
To display all databases:
show databases;
Use a database:
Use DatabaseName;
Show all tables for a database:
Show tables;
Exit:
Quit
deleting databases and data tables
Mysql>drop database name;
Mysql>drop table Data Sheet name;
User-Related: View all users:
SELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;
New User:
Insert into Mysql.user (Host,user,password) VALUES ("localhost", "Test", Password ("1234"));
The last three parameters are login IP, username, password
To authorize a user:
Format: Grant permissions on database. * To username @ Login host identified by "password"; Example: Grant all privileges on testdb.* to [email protected] identified by ' 1234 ';
Then you need to execute the command to refresh the permissions: Flush privileges;
To grant a user partial permissions:
Grant Select,update on testdb.* to [e-mail protected] identified by ' 1234 ';
Grant certain permissions to a user for all databases:
Grant Select,delete,update,create,drop on * * to [e-mail protected] "%" identified by "1234";
To delete a user:
Delete from user Where user= ' test ' and host= ' localhost ';
then refresh the permissions;
Delete account and permissions: >drop user username @ '% ';
>drop user username @ localhost;
Modify the specified user password
Log in with Root:
Mysql-u root-p
Execute command:
Update Mysql.user set Password=password (' New password ') where user= "test" and host= "localhost";
Refresh permissions:
Flush privileges;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux MySQL add users, delete users, and user permissions