当前位置:网站首页>MySQL-08

MySQL-08

2022-06-26 05:58:00 Mr.Rop

8、 Rights management and backup

8.1、 User management

SQLyog Visual management
 Insert picture description here

SQL The command operation

User table :mysql.user

The essence : Add, delete, modify and check this table

--  Create user  CREATE USER  user name  IDENTIFIED BY ' password ';
CREATE USER zourong IDENTIFIED BY '123456';

--  Change Password ( Change the current user password )
SET PASSWORD = PASSWORD('123456');


--  Change Password ( Change the specified user password )
SET PASSWORD FOR zourong=PASSWORD('123456')

--  rename  RENAME USER  Original name  TO  New name ;
RENAME USER zourong2 TO zourong;

--  User authorization  ALL PRIVILEGES-> All permissions   library . surface 
-- ALL PRIVILEGES  In addition to empowering others , Everything else can 
GRANT ALL PRIVILEGES ON *.* TO zourong;

--  View permissions 
SHOW GRANTS FOR zourong;
SHOW GRANTS FOR root@localhost;

-- ROOT User permissions :GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION

--  Revoke authority  REVOKE  What authority , In which library , To whom 
REVOKE ALL PRIVILEGES ON *.* FROM zourong;

--  Delete user 
DROP USER zourong;

8.2、MySQL Backup

Why backup

  • Ensure that important data is not lost
  • Data transfer A—>B

MySQL Database backup mode

  • Copy physical files directly

  • stay SQLyog Manually export... In this visualization tool

    • In the table or library you want to export , Right click , Select backup or export
    •  Insert picture description here
  • Use the command line to export mysqldump Command line

    # mysqldump -h  host  -u  user name  -p  password   database   Table name  > Physical disk location / file name 
    mysqldump -hlocalhost -uroot -p123456 school student >D:/a.sql
    
    # mysqldump -h  host  -u  user name  -p  password   database   surface 1  surface 2  surface 3 > Physical disk location / file name 
    mysqldump -hlocalhost -uroot -p123456 school student result>D:/b.sql
    
    # mysqldump -h  host  -u  user name  -p  password   database  > Physical disk location / file name 
    mysqldump -hlocalhost -uroot -p123456 school>D:/c.sql
    
    #  Import 
    #  In case of login , Switch to the specified database 
    # source  Backup file 
    source D:/b.sql
    
    mysql -u user name  -p123456  Library name < Backup file 
    

Suppose you want to back up the database , Prevent data loss

Give the database to others ,sql Just give the document

原网站

版权声明
本文为[Mr.Rop]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180503012723.html