Summary of simple knowledge and orders for MySQL interview
For children's shoes interviewing for MySQL positions, most interviewers will test the following simple MySQL knowledge and commands:
1. How to determine whether MySQL starts and how to start and shut down MySQL
Service mysql status/start/stop
/ etc/init.d/mysql status/start/stop
Ps-ef | grep mysql
two。 How to log in to MySQL
Mysql [db_name]-u [username]-p [password]-h [hostname | IP]
For example: mysql-uroot-p123456-h 192.168.1.1
3. How to create and delete databases
CREATE DATABASE [IF NOT EXISTS] db_name
[DEFAULT] CHARACTER SET charset_name
| | [DEFAULT] COLLATE collation_name |
DROP DATABASE [IF NOT EXISTS] db_name
4. How to create and delete tables
CREATE TABLE [IF NOT EXISTS] table_name
Col_name1 DATATYPE,col_name2 DATATYPE,... , CONSTRAINT)
ENGINE=engine_name DEFAULT CHARSET=charset_name
DROP TABLE [IF NOT EXISTS] table_name
5. How to insert data
INSERT INTO table_name [col_name1,col_name2, … ,]
VALUES (v1Jing v2, … ,)
INSERT INTO table_name [col_name1,col_name2, … ,]
SELECT_STATMENT
6. How to create a user
Mysql > create user username@'IP' identified by 'your_password'
Mysql > grant all privileges on DB_name.* to username@'IP' identified by 'your_password'
7. How to change a user's password
Method 1:
Mysqladmin-u root-p [your _ password] password 123456
Method 2:
Mysql > use mysql
Mysql > update user set password=password ('123456') WHERE user='root'
Mysql > flush privileges
Method 3:
Mysql > set password for 'scott'@'localhost'=password (' tiger')
8. Other simple commands
Check the version of MySQL: SELECT version ()
Check the version of InnoDB: SELECT @ @ innodb_version
View the user who is currently logged in to MySQL: select user ()
Check what databases are available under the user: show databases
Use a database: use db_name
View the database name that is currently in use: select database ()
See which tables are available in a database: show tables
View the table structure and create statements: desc table_name; | show create table_name
View the creation statement of the database: show create db_name
View warning:show warnings
View MySQL error: show errors
View server status variables, running server statistics and status metrics: show global status like'% tables%'
Looking at the server system variable, the value of the variable actually used is: show global variables like'% sql_mode%'