數據庫遷移:
1.安裝一臺環境一模一樣的機器
1.1安裝mysql5.5.49
2.原機器數據庫導出數據到/tmp/all.sql.gz
scp到新機器
3.新機器導入數據
3.1創建用戶,授權。
4.修改wp-config.php配置文件
define('DB_HOST','xxx.xx.xx.x')
新建一mysql虛擬機
hostname: db01
eth0:192.168.10.10/24
eth1:172.16.10.x/24
導出LNMP(web01)中的wordpress數據庫數據
mysqldump -uroot -plihao123 wordpress -B |gzip>bak.sql.gz
拷貝到db01的數據庫中
scp bak.sql.gz [email protected]:/tmp
解壓並導入51的數據庫中
[root@db01 tmp]# gzip -d bak.sql.gz
[root@db01 tmp]# mysql -uroot -plihao123 </tmp/bak.sql
[root@db01 tmp]# mysql -uroot -plihao123 -e "show databases like 'wordpress'"
+----------------------+
| Database (wordpress) |
+----------------------+
| wordpress |
+----------------------+
爲此數據庫創建一個wordpress管理員用戶, 進行數據庫授權,讓web01可以訪問
mysql> grant all on wordpress.* to wordpress@'172.16.10.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
停止掉web01中的數據庫服務並測試
[root@web01 tools]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@web01 tools]# lsof -i :3306
[root@web01 tools]# chkconfig mysqld off
測試訪問
修改wordpress中的數據庫配置文件/application/nginx/html/blog/ wp-config.php中的
主機IP地址爲db01的內網IP地址。
[root@web01 tools]# cd /application/nginx/html/blog/
[root@web01 blog]# vim wp-config.php #把這個配置文件中的主機名改成db01(172.16.10.x)
/* MySQL主機 /
define('DB_HOST', '172.16.10.X');