mysql-备份和恢复
                        
                            时间:2021-07-01 10:21:17
                            帮助过:4人阅读
							                        
                     
                    
                    
                    -u 
user_name -p password database_name 
>file_name.sql
    
数据库还原:
    法一:
    ① 创建数据库:
    ② 还原:mysql -u 
user_name -p password database_name 
< file_name.sql(全路径)
    法二:
       还原:source file_name.slq(全路径)  将数据库还原到当前数据库
       
创建用户:(必须在root中才能创建用户)
    法一:
    create user ‘user_name‘@
‘localhost‘ identified 
by ‘password‘;
    法二:直接操作user表
    insert into mysql.
user(Host,
User,authentication_string,ssl_cipher,x509_issuer,x509_subject) 
    values (
‘localhost‘,
‘user_name‘,PASSWORD(
‘password‘),
‘‘,
‘‘,
‘‘);  操作以后必须 flush 
privileges
        
删除用户:
     法一:
     drop user ‘user_name‘@
‘localhost‘;
     法二:直接操作user表
     delete from mysql.
user where host
=‘localhost‘ and user=‘user_name‘;
     删除以后必须flush privileges(刷新权限)
         
修改用户密码:
     法一:
     mysqladmin -u 
user_name -pold_password password new_password;
     法二:要先登录用户
     set password
=new_password; 在root用户登录的时候
     法三:先登录root用户,直接操作user表中的authentication字段来修改密码
     update mysql.
user set authentication_string
=PASSWORD(
‘password‘) 
where host
=‘localhost‘ and user=‘user_name‘;
     法四:普通用户在登录到当前用户下,修改当前
     set password
=password(
‘new_password‘);
     set password 
for ‘user_name‘@
‘localhost‘=password(
‘new_password‘);
     
刷新:
    flush privileges;(直接操作user表的都要flush 
privileges)
    
    每一个用户资料都是user表中的一条记录
 
mysql-备份和恢复
标签:and   mysq   creat   备份   tab   .sql   rom   style   where