Apache和PHP是一個總體,由於PHP是以一個模塊的形式和Apache結合在一塊兒,可是Apache不能直接和MySQL去鏈接,只能經過PHP這個模塊去MySQL中提取數據,拿到數據後,PHP把這個結果交給Apache,Apache再交給用戶。html
PHP和MySQL交互數據的操做、行爲,稱爲 動態請求。python
最新版本5.7GA/8.0DMRmysql
MySQL5.6變化比較大,5.7性能上有很大提高linux
rpm包——>直接yum安裝便可git
源碼包——>web
二進制免編譯包——>這種包至關因而在發佈以前,先在一臺linux服務器上作了編譯,編譯完以後,把編譯完成的文件從新安排放到一個目錄下去,而後在打包壓縮,最後再發布sql
[root@yong-01 src]# cd /usr/local/src/
[root@yong-01 src]# uname -a //查看平臺,是多少位的 Linux yong-01 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz shell
[root@yong-01 src]# ls mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [root@yong-01 src]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz 解壓文件過程
[root@yong-01 src]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
[root@yong-01 src]# cd /usr/local/mysql/ [root@yong-01 mysql]# ls bin data include man README share support-files COPYING docs lib mysql-test scripts sql-bench
[root@yong-01 mysql]# useradd mysql
[root@yong-01 mysql]# mkdir /data/
[root@yong-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
[root@yong-01 mysql]# yum list |grep perl |grep -i dumper perl-Data-Dumper.x86_64 2.145-3.el7 base perl-XML-Dumper.noarch 0.81-17.el7 base
[root@yong-01 mysql]# yum install -y perl-Data-Dumper
[root@yong-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@yong-01 mysql]# yum install -y libaio
[root@yong-01 mysql]# echo $? 0
[root@yong-01 mysql]# ls support-files/my-default.cnf support-files/my-default.cnf //mysql的模板配置文件 [root@yong-01 mysql]# ls /etc/my.cnf /etc/my.cnf //mysql的配置文件就叫作my.cnf,並且固定放在 /etc下
[root@yong-01 mysql]# rpm -qf /etc/my.cnf mariadb-libs-5.5.56-2.el7.x86_64
[root@yong-01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@yong-01 mysql]# vim /etc/init.d/mysqld //編譯配置文件 把 basedir=/usr/local/mysql //指定你的程序目錄,放到/usr/local/mysql 下 把 datadir=/data/mysql //定義到/data/mysql 而後保存退出
[root@yong-01 mysql]# ls -l /etc/init.d/mysqld -rwxr-xr-x 1 root root 10904 5月 23 22:24 /etc/init.d/mysqld
[root@yong-01 mysql]# chkconfig --add mysqld [root@yong-01 mysql]# chkconfig --list 注意:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置數據可能被原生 systemd 配置覆蓋。 若是您想列出 systemd 服務,請執行 'systemctl list-unit-files'。 欲查看對特定 target 啓用的服務請執行 'systemctl list-dependencies [target]'。 mysqld 0:關 1:關 2:開 3:開 4:開 5:開 6:關 netconsole 0:關 1:關 2:關 3:關 4:關 5:關 6:關 network 0:關 1:關 2:開 3:開 4:開 5:開 6:關
[root@yong-01 mysql]# service mysqld start Starting MySQL.Logging to '/data/mysql/yong-01.err'. SUCCESS! [root@yong-01 mysql]# ps aux |grep mysql root 2126 0.0 0.0 11768 1588 pts/0 S 22:26 0:00 /bin/sh /usr/local/mysql//bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/yong-01.pid mysql 2261 2.3 23.9 973056 449504 pts/0 Sl 22:26 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/yong-01.err --pid-file=/data/mysql/yong-01.pid --socket=/tmp/mysql.sock root 2285 0.0 0.0 112676 984 pts/0 S+ 22:27 0:00 grep --color=auto mysql [root@yong-01 mysql]# netstat -lntp //查看監聽的端口,3306端口 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1123/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1471/master tcp6 0 0 :::22 :::* LISTEN 1123/sshd tcp6 0 0 ::1:25 :::* LISTEN 1471/master tcp6 0 0 :::3306 :::* LISTEN 2261/mysqld
啓動方法: [root@yong-01 mysql]# service mysqld stop //首先先停掉mysqld服務 Shutting down MySQL.. SUCCESS! [root@yong-01 mysql]# ps aux |grep mysql //查看mysqld進程是否還在 root 2517 0.0 0.0 112676 984 pts/0 R+ 22:33 0:00 grep --color=auto mysql [root@yong-01 mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql & //命令行的方式啓動,先指定配置文件所在路徑,而後指定user用戶,指定datadir(這個datadir也能夠在my.cnf 文件中去定義的),再加一個& 符號,丟到後臺去 [1] 2537 [root@yong-01 mysql]# 180523 22:36:14 mysqld_safe Logging to '/data/mysql/yong-01.err'. 180523 22:36:14 mysqld_safe Starting mysqld daemon with databases from /data/mysql [root@yong-01 mysql]# ps aux |grep mysql //查看是否啓動 root 2537 0.0 0.0 113264 1608 pts/0 S 22:36 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql mysql 2660 0.5 23.9 973056 449496 pts/0 Sl 22:36 0:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/yong-01.err --pid-file=/data/mysql/yong-01.pid --socket=/tmp/mysql.sock root 2687 0.0 0.0 112676 980 pts/0 R+ 22:37 0:00 grep --color=auto mysql [root@yong-01 mysql]# netstat -lntp //查看端口 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1123/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1471/master tcp6 0 0 :::22 :::* LISTEN 1123/sshd tcp6 0 0 ::1:25 :::* LISTEN 1471/master tcp6 0 0 :::3306 :::* LISTEN 2660/mysqld
[root@yong-01 mysql]# killall mysqld [root@yong-01 mysql]# ps aux |grep mysql root 2292 0.0 0.0 112676 984 pts/0 R+ 22:28 0:00 grep --color=auto mysql