MySQL beginner's notes ① and mysql beginner's notes
1. MySQL Login
MySQL-u username-p
2. Create a user in MySQL
Use mysql // enter the mysql table
Insert into user (Host, User, Password) VALUES ('%', 'username', PASSWORD ('Password ')); // % indicates that any IP address can be accessed. You can directly enter IP address control to log on to localhost, indicating smart local login.
3. user permission management
1) Set permissions
Grant all on db_name.tb_name to 'username' @ 'host'; // all indicates all the permissions in the current database. select indicates the query permission, update delete, and other permissions (separated by commas) db_name indicates the name of the table to be authorized, and tb_name indicates the name of the table in the database * indicates all
2) delete permissions
Revoke all on db_name.tb_name to 'username' @ 'host'; // if you do not have the permission to delete the file, an error is returned.
3) directly delete a user
Delete from mysql. user WHERE User = 'username' and Host = '% ';
Note:
After setting a user and granting the user permission, remember to refresh the permission and flush privileges;