码迷,mamicode.com
首页 > 数据库 > 详细

mysql-备份和恢复

时间:2017-06-08 23:35:36      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:and   mysq   creat   备份   tab   .sql   rom   style   where   

数据库备份:
    mysqldump -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   

原文地址:http://www.cnblogs.com/oural-yan/p/6952558.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!