1. Change the password
Without knowing the original password: the process of shutting down MySQL
Enter "Mysqld_safe--skip-grant-tables &" command to enter MySQL Safe mode without password.
Then you can use a blank password like mysql-u root
show databases; View current database
Use tables; View the current table
Update user set password= ("New password") where user= ' root ' can change the password.
Enter "flush privileges;" Update permissions.
Then restart the service.
2. Create a new user
After entering MySQL, use MySQL.
Create user ' sz ' @ ' localhost ' indentified by ' 123456 ' creates a username of sz password 123456 login locally
Flush Privilegs Update Permissions
3. Give MySQL user permissions
All: All available permissions
Create: Creating libraries, tables, and indexes
Lock_tables: Lock Table
Alter: Modify Table
Delete: Deleting a table
Insert: Inserting a table or column
SELECT: Retrieving data for a table or column
Create_view: Creating a View
Show_databases: List Database
Drop: Delete libraries, tables, and views
Run the command to give the user permission
Grant create on Mysql.user to ' sz ' @ ' localhost ';
Cases:
Full permissions granted to the user
Show grant for ' sz ' @ ' localhost ';
Remove all user rights
Remove permission on the table name for ' sz ' @ ' localhost ';
Last refresh permission flush Privilegs;
Create a user who can connect to the server from anywhere.
Grant all privileges on * * to [e-mail protected] identified by ' something ' with
Root can log on outside
Use MySQL;
Grant all privileges on * * to [email protected] '% ' identified by ' root ' with GRANT OPTION;
Flush privileges;
2. Basic commands
DESC user; View all information in a table
Mysql Basic Life