47day博客搭建 数据库迁移

一,博客搭建

1、确认环境

[root@web02 ~]# netstat -lntup|egrep "80|3306|9000"

tcp        0      0 127.0.0.1:9000          0.0.0.0:*              LISTEN      12214/php-fpm: mast

tcp        0      0 0.0.0.0:80              0.0.0.0:*              LISTEN      12420/nginx: master

tcp6      0      0 :::3306                :::*                    LISTEN      7285/mysqld 

2、下载上传开源BLOG,解压,权限

[root@web02 ~]#  cd /server/tools/

[root@web02 /server/tools]# rz -y

rz waiting to receive.

[root@web02 /server/tools]# ls

libiconv-1.16                              nginx-1.16.0        php-7.3.5.tar.gz

libiconv-1.16.tar.gz                        nginx-1.16.0.tar.gz  wordpress-5.1.1.zip

mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz  php-7.3.5

[root@web02 /server/tools]# unzip wordpress-5.1.1.zip

在[root@web02 /server/tools]# /application/nginx/html/下创建,workdpress

[root@web02 /server/tools]# mv wordpress/* /application/nginx/html/workdpress

给/application/nginx/html/workdpress 权限

[root@web02 /server/tools]# chown -R nginx.nginx /application/nginx/html/workdpress/ (暂时性)

[root@web02 /server/tools]# ls -ld /application/nginx/html/blog/

drwxr-xr-x 5 nginx nginx 4096 5月  7 09:14 /application/nginx/html/blog/

3,设置nginx 配置文件

[root@web02 /application/nginx/conf]#cat nginx.conf

worker_processes  1;

events {

    worker_connections  1024;

}

http {

    include      mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

server {

        listen      80;

       server_name blog.etiantian.org;

         root  html/wordpress;

            index  index.php index.html index.htm;

        }

        location ~ .*\.(php|php5)?$ {

         root html/wordpress;

            fastcgi_pass  127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

        }

    }

4,[root@web02 /application/nginx/html/wordpress]#cp wp-config-sample.php wp-config.php

wp-config.php的主要配置

[root@web02 /application/nginx/html/wordpress]#cat wp-config.php

/** The name of the database for WordPress */

define( 'DB_NAME', 'wordpress' );

/** MySQL database username */

define( 'DB_USER', 'root' );

/** MySQL database password */

define( 'DB_PASSWORD', 'oldboy123' );

/** MySQL hostname */

define( 'DB_HOST', '172.16.1.51' );

二,数据迁移

#数据库迁移:

从单机web02迁移到DB01独立的mysql

1,web02:压缩:

[root@web02 ~]# mysqldump -uroot -poldboy123 -A -B|gzip >/tmp/web02_db.sql.gz

mysqldump: [Warning] Using a password on the command line interface can be insecure.,

2,拷贝到异机DB01:

[root@web02 ~]# scp /tmp/web02_db.sql.gz 10.0.0.51:/tmp

3,把web02的数据库关闭

systemctl stop mysqld

systemctl disable mysqld

lsof -i :3306

4,配置web02的wp-config.php

[root@web02 /application/nginx/html/WordPress]# vim wp-config.php

define( 'DB_NAME', 'wordpress' );

/** MySQL database username */

define( 'DB_USER', 'wordpress' );

/** MySQL database password */

define( 'DB_PASSWORD', 'oldboy123' );

/** MySQL hostname */

define( 'DB_HOST', '172.16.1.51' );   #DB01的ip

5,在DB01解压web02传过来的数据库:

[root@db01 ~]# cd /tmp

[root@db01 /tmp]# gzip -d web02_db.sql.gz

[root@db01 /tmp]# mysql </tmp/web02_db.sql

grant all privileges on wordpress.* to wordpress@'172.16.1.%' identified by 'oldboy123';

flush privileges;

select user,authentication_string,host from mysql.user;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • LNMP Web服务搭建 mysql与php安装 1、JAVA Web环境(企业更多) [tomcat(jvm)]...
    高博666阅读 612评论 0 0
  • 今天整理书桌,重看了《过于喧嚣的孤独》,这是我见过的世上最盛大的孤独,这份孤独藏在捷克六七十年代一个阴暗的废...
    风的筝阅读 356评论 0 0
  • 我不爱晒自拍照 不去拍我吃的用的 旅行的时候更多是记录下有趣的瞬间 所以我才没有被拍拍拍束缚把吧 不需要去炫耀独特...
    percy0016阅读 129评论 0 0
  • 东西都扔了,evd,小霸王,还有我珍藏多年的手机,钥匙链。还有那个破碎掉的观音等等,好多。老版一元的还有豹子号的百...
    一个说书人阅读 139评论 0 0
  • 【 丁师答:为什么拍打释放情绪 】 学员:早上拍我有很多的情绪释放,这是不由自主的彻底释放,我想搞清楚为什么简简单...
    楚楚点点阅读 490评论 0 0