Using mysql



1. Login, you can use the password to log in, or you can use no password to log in. Mysql -u username -p password



Mysql -u root -p












Mysql -u root // Login without password






2, Exit, command “quit”



quit






3. Create a database and run the create database name command. , notice the semicolon after this command



create database test1;









4. Run show Databases;



show databases;

































5. Drop database database name.



drop database test1;









6. Set permissions

























































Grant permission on database file to username@ip identified by ‘password’; . With Grant, if the user does not already exist, create the user.






 grant insert on test01.* to david@localhost identified by ‘123456’;












 grant all privileges on *.* to david@’%’ identified by ‘123456’;












2) Run the select host, user from mysql.user command to check all permissions of the current database.



select host,user from mysql.user;













































3) Check the rights of the current login user and run the “show grants” command.



show grants;



























4) Check the privileges of a user on a machine and run the “show grants for user@ip” command.



show grants for david@localhost;






























Revoke permission on database files from user@ip



 revoke all privileges on *.* from david@’%’;









show grants for david@localhost; // Delete it



























6) Delete user from user where user= ‘username’



use mysql; // Call this command first















delete from user where user=’david’; // Delete the user









select host,user from mysql.user; // View the user