当前位置:网站首页>MySQL differential deletion and modification check user login and password modification

MySQL differential deletion and modification check user login and password modification

2022-07-19 02:47:00 For whom do the stars change

1、  Sign in MySQL database

netstat -anpt | grep mysqld    ( Check the port )

mysql -u root ( Password-free login )

mysql -u root -p ( Login with password )

2、 view the database

show  databases; (; The end of the statement )

( The following is the display )

mysql> show  databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.10 sec)

3、 View which tables are in the currently used library

use mysql;    ( Switch to MySQL database )


show tables;    ( See the table )


describe user;    ( View the structure of the table )

select * from  Table name      ( View all data )

4、 Create libraries and tables

        (1) Create a library  

create database benet;  ( establish benet database )

    ( The following is the display )
Query OK, 1 row affected (0.00 sec)




        (2) Create table

 Create a new table 

CREATE TABLE  Table name ( Field 1  name   type , Field 2  name   type ,...,);
( The following are examples )

create table  student (xuehao int,xingming char(20),xingbie char(4));

5、 Insert and delete and change

        (1) Insert  



INSERT INTO  Table name ( Field 1, Field 2,…)VALUES( Field 1 Value , Field 2 Value ,…)

    ( give an example )

insert into student (xuehao,xingming,xingbie) values('1','zhangsan','nan');

        (2) Delete

 Delete a database 

DROP DATABASE  Database name 




 Delete a table in a database 

DROP TABLE  Database name . Table name ;




 Delete a piece of data of a table in a database 

delete from  Table name  where   Conditions 

        (3) change  

         Modifying data 

update  Table name  set  Name =' value ' where  Conditions ;

6、 Set user permissions

        (1) Create database users  

grant  Permission list  on  Database name . Table name  to  user name @ Source address   identified by ' password ';



 remarks :
 Permission list :select( View permissions ) insert( Insert permissions )  update( Change permissions ) all( All permissions )

 Source address :  192.168.1.10  ( Represents a host )
           192.168.1.%   ( Represents a network segment )
           localhost     ( Indicating the machine )


         If there is no user, the user is automatically created 

        (2) Revoke user privileges

revoke     Permission list  on  Database name . Table name  from   user name @ Address source 

        (3) View user permissions  

show grants  for   user name @ Address source 

原网站

版权声明
本文为[For whom do the stars change]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207170009270580.html