• Mysql 逻辑备份>>>>完全备份恢复


    首先用mysqldump进行完全备份

    [root@logan ~]# mysqldump -uroot -p123 --all-databases > /my_autofs/all.sql
    mysqldump: [Warning] Using a password on the command line interface can be insecure.

    停掉mysql服务

    [root@logan my_autofs]# killall mysqld
    mysqld: no process found

    手动建立/usr/local/mysql/data mulu

    [root@logan mysql]# chown -R mysql.mysql data/
    [root@logan mysql]# ll -d data/
    drwxr-xr-x 2 mysql mysql 6 7月   3 16:28 data/

    初始化mysql

    [root@logan my_autofs]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data
    2019-07-03T08:17:14.051524Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2019-07-03T08:17:14.537987Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2019-07-03T08:17:14.654008Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2019-07-03T08:17:14.712419Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: f6f91572-9d6a-11e9-94ea-000c29d7f62f.
    2019-07-03T08:17:14.713328Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2019-07-03T08:17:14.713951Z 1 [Note] A temporary password is generated for root@localhost: Fp6rfD?e,quk     #这是初始密码
    [root@logan my_autofs]# 

    重启服务,登录

    [root@logan my_autofs]# systemctl restart mysqldd
    [root@logan my_autofs]# mysql -uroot -pFp6rfD?e,quk
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.25
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> 

    修改数据库密码

    mysql> set password=password('123');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> 

    查看当前数据库

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+

    恢复备份

    [root@logan mysql]# mysql -uroot -p123 < /my_autofs/all.sql 
    mysql: [Warning] Using a password on the command line interface can be insecure.

    重新登录进行查看

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | file               |
    | file1              |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    6 rows in set (0.00 sec)

    原来的数据回来了

  • 相关阅读:
    备份恢复八大核心
    ORACLE CentOS5.6安装
    ORA-00205
    sf02_选择排序算法Java与Python实现
    解决SQL命令行回退的问题
    redhat 6.4 yum 本地配置简记
    ORA-12705: Cannot access NLS data files or invalid environment specified
    asmca无法创建ASM磁盘
    Sort List
    Merge k Sorted Lists
  • 原文地址:https://www.cnblogs.com/loganSxb/p/11127589.html
Copyright © 2020-2023  润新知