zoukankan      html  css  js  c++  java
  • MYSQL逻辑备份

    首先用mysqldump进行完全备份

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

    停掉mysql服务

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

    手动建立/usr/local/mysql/data 目录

    [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]# /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]# systemctl restart mysqldd
    [root@logan]# 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 < /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)
  • 相关阅读:
    递归函数及Java范例
    笔记本的硬盘坏了
    “References to generic type List should be parameterized”
    配置管理软件(configuration management software)介绍
    WinCE文件目录定制及内存调整
    使用Silverlight for Embedded开发绚丽的界面(3)
    wince国际化语言支持
    Eclipse IDE for Java EE Developers 与Eclipse Classic 区别
    WinCE Heartbeat Message的实现
    使用Silverlight for Embedded开发绚丽的界面(2)
  • 原文地址:https://www.cnblogs.com/MR-ws/p/11127855.html
Copyright © 2011-2022 走看看