zoukankan      html  css  js  c++  java
  • 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)

    原来的数据回来了

  • 相关阅读:
    按单生产案例
    【转】linux中执行外部命令提示" error while loading shared libraries"时的解决办法
    【转】WARNING! File system needs to be upgraded. You have version null and I want version 7. Run the '${HBASE_HOME}/bin/hbase migrate' script. 的解决办法
    根据Rowkey从HBase中查询数据
    【转】在一个Job中同时写入多个HBase的table
    sqoop 使用
    给VMware下的Linux扩展磁盘空间(以CentOS6.3为例)
    chrome 版本 29.0.1547.76 m 解决打开新标签页后的恶心页面的问题
    tomcat7+jdk的keytool生成证书 配置https
    如何打包和生成你的Android应用程序
  • 原文地址:https://www.cnblogs.com/loganSxb/p/11127589.html
Copyright © 2011-2022 走看看