假设: centos服务器AB两台,A上的生产MySQL出现故障不能启动,但是数据文件是完好无损的。现在需要在B服务器上恢复数据库。
开始模拟
准备两台centos7虚拟机
192.168.27.136 A
192.168.27.136 B
安装mysql数据库
[root@localhost ~]# yum -y install mariadb mariadb-server
A上操作
1. 启动数据库 创建库表并插入数据(写点数据)
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database www character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]