Build Library
CREATE DATABASE IF not EXISTS gloryroad DEFAULT CHARSET UTF8 COLLATE
Utf8_general_ci;
Build table
CREATE TABLE Studentinfo (
ID int NOT NULL auto_increment comment "non-nullable self-growing primary key ID",
student_id varchar () NOT NULL,
Name varchar (+) is not NULL,
Sex char (4),
Tel varchar (+) unique NOT NULL,
admissiondate datetime default ' 0000:00:00 00:00:00 ',
Primary KEY (ID),
Unique student_id (student_id)
) Engine=innodb Character Set UTF8 comment "Student information sheet";
See which databases are available
Show DATABASES
Choose to use that database
Use Python
See what database tables are available
Show TABLES
Deleting a database
Drop TABLE Demo;
Create a database user
Create USER ' hhq ' @ '% ' identified by "123456";
% can specify IP, only the person with the specified IP can connect to this database
Update the value of a table field
Update USER set Password=password (' 11111 ') where user= ' hhq1 '
Assigning Permissions to users
GRANT all privileges in . to [email protected] '% ' identified by ' 123456 '
Flush privileges;
Use Python;
SELECT database (); View the current library
View current Connected Users
SELECT user ();
Common database operation statements (1)