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