1. Add users//Create a new usercreate user username identified by 'password'; //View existing users and host names select user,host from mysql.user; 2. Change the username and host//Change the username rename user 'original username'@'host' to 'new username'@'host'; 3. Change your password//Change password mysqladmin -u user -p original password password new password 4. Delete User//Delete user drop user username@'host'; 5. Query all users and hosts//View existing users and host names select user,host from mysql.user; 6. View the database//View the database SHOW DATABASES; 7. Create a database//Create a database CREATE DATABASE database name; 8. View database definition information//View the database definition information SHOW CREATE DATABASE database name; 9. Delete the database//Delete the database DROP DATABASE database name; 10. Refresh permissions//Flush the MySQL privilege table FLUSH PRIVILEGES; 11. Common commands are as follows//Login to mysql -u user -p password mysql -u user -p password -h host IP //Change the command name prompt \u@\h \d prompt mysql \d> prompt mysql (\d)> //Display the current server versionSELECT VERSION(); //Display the current dateSELECT NOW(); //Display the current userSELECT USER(); //Set the client encoding SET NAMES gbk; //Show the opened database SELECT DATABASE(); //View the port show global variables like 'port'; //View existing users and host names select user,host from mysql.user; //Create a new usercreate user username identified by 'password'; //Delete user drop user username@'host'; //Change the username rename user 'original username'@'host' to 'new username'@'host'; //Change password mysqladmin -u user -p original password password new password update mysql.user set password = password('password') where user = 'user' and host = 'host'; //Authorize grant all privileges on zhangsanDb.* to zhangsan@'%' identified by 'zhangsan'; all privileges: All privileges. select: Read permission. delete: Delete permission. update: Update permission. create: Create permission. drop: delete database and table permissions. Username@host represents the authorized user and the IP address that the user is allowed to log in. There are several types of Host: localhost: This user is only allowed to log in locally and cannot log in remotely. %: Allow remote login from any machine except the local machine. 192.168.52.32: The specific IP means that the user is only allowed to log in from the specific IP. //View the information of newly added database permissions select user,Db,host,select_priv,insert_priv,update_priv,delete_priv from mysql.db where user='zhangsan'; //Flush the MySQL privilege table FLUSH PRIVILEGES; //Create a database CREATE DATABASE database name; CREATE DATABASE IF NOT EXISTS database name; -- Create it if it does not exist. CREATE DATABASE IF NOT EXISTS database name CHARACTER SET gbk; //Modify the database ALTER DATABASE database name CHARACTER SET = utf8; //View the database SHOW DATABASES; //View the database definition information SHOW CREATE DATABASE database name; //Delete the database DROP DATABASE database name; //If the database exists, delete it DROP DATABASE IF EXISTS database name; //Switch database USE database name; //View all tables in the database SHOW TABLES; //View a database table SHOW TABLES FROM database name; //View the table structure DESC table name; SHOW COLUMNS FROM table name; //View the table statement SHOW CREATE TABLE table name; //Delete table DROP TABLE table name; Modify table // delete column alter TABLE table name DROP column name; //Change the name of the table RENAME TABLE table name TO new table name; //Modify the table character set alter TABLE table name CHARACTER SET character set //Modify the column name alter TABLE table name CHANGE column name new column name column type; //Add columns alter table table name add column name column type; This is the end of this article about MySQL database terminal - common operation command codes. For more relevant MySQL database common operation command codes, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A few things about favicon.ico (it’s best to put it in the root directory)
>>: Text pop-up effects implemented with CSS3
Use "onInput(event)" to detect whether ...
To perform incremental backup of the MySQL databa...
RDF and OWL are two important semantic web techno...
There are also two servers: Preparation: Set the ...
First download the compressed package of nacos fr...
1. Download, I take 8.0 as an example Download ad...
The root account of mysql, I usually use localhos...
Table of contents 1. prototype (explicit prototyp...
I have been researching Linux recently and tried ...
This article example shares the specific code of ...
Table of contents Tutorial Series 1. Introduction...
Table of contents Dynamically change themes The f...
Table of contents Problem Description The general...
This article shares the specific code of Vue3.0 h...
Abstract: When people talk about MySQL performanc...