因為 WordPress 在安裝時會把網路的設定寫入到資料庫,所以當更換 IP 時,就會有無法連線的問題。

[@more@]解決方法:
參考網頁:
wordpress 修改IP地址后进不去后台的解决方法_wordpress_新浪轻博客
1. 使用 SQL 指令 紅色的 IP 就是新的 IP
# /usr/bin/mysql -u root -p wordpress
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 16
Server version: 10.0.14-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
MariaDB [wordpress]> update wp_options set option_value = ‘http://192.168.1.109/wordpress’ where option_name = ‘siteurl’ or option_name = ‘home’;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0
MariaDB [wordpress]> quit
Bye2. 使用 Script 紅字部分代表是 root SQL 的密碼
# vim /usr/local/bin/setwordpressip
#! /bin/bash
# set wordpress admin ip
param=$#
if [ $param -eq 1 ]; then
echo “update wp_options set option_value = ‘http://”$1″/wordpress’ where option_name = ‘siteurl’ or option_name = ‘home’;” > setwordpress.tmp
mysql -uroot -p123456 wordpress < setwordpress.tmp
rm setwordpress.tmp
echo “OK…”
exit 0
fi
echo “use: $0 IP Address (127.0.0.1)”
更改權限
# chmod 700 /usr/local/bin/setwordpressip
使用方式
# /usr/local/bin/setwordpressip 192.168.1.109