Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of simple knowledge and orders for MySQL interview

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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%'

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report