MySQL、MariaDB 資料庫匯入與匯出

匯出資料庫

mysqldump -u username -p database_name > data-dump.sql
  • username 資料庫的使用者名稱
  • database_name 要匯出的資料庫名稱
  • data-dump.sql 要匯出的 sql 檔案名稱

匯入資料庫

mysql -h hostname -u username -ppassword --default-character-set=utf8 database_name < data-import.sql
  • hostname 伺服器名稱或 IP 位址
  • username 資料庫的使用者名稱
  • password 資料庫的使用者密碼(注意,密碼和 -p 之間沒有空格)
  • database_name 要匯入的資料庫名稱
  • data-import.sql 要匯入的 sql 檔案名稱

LAMP on CentOS 7

Apache

# Step 1: Install Apache
yum clean all
yum -y update
yum -y install httpd

# Step 2: Allow Apache Through the Firewall
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload

# Step 3: Configure Apache to Start on Boot
systemctl start httpd
systemctl enable httpd

PHP 7

# CentOS/RHEL 7.x
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# Install php 7
yum -y install php70w php70w-opcache

MySQL / MariaDB

# Install MySQL / MariaDB
yum -y install mariadb-server mariadb
systemctl start mariadb
systemctl enable mariadb

phpMyAdmin

# Step 1: Add the EPEL Repository
rpm -iUvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# Step 2: Install phpMyAdmin
yum -y update
yum -y install phpmyadmin

# Step 3: Basic Configuration for phpMyAdmin
vi /etc/httpd/conf.d/phpMyAdmin.conf
systemctl restart httpd

SELinux

# Disabled SELINUX
vi /etc/sysconfig/selinux
set SELINUX=disabled

Apache: Options +Indexes still results in 403 Forbidden

httpd.conf
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName sandbox.mysite.internal
    DocumentRoot /var/www/vhosts/sandbox/mysite
    ErrorLog logs/sandbox/mysite-error.log
    CustomLog logs/sandbox/mysite-access.log common
    <Directory /var/www/vhosts/sandbox/mysite/test/>
        Order allow,deny
        Allow from all
        Options +Indexes
    </Directory>
</VirtualHost>