二进制格式mysql安装说明(mysql-5.5.49)
# less INSTALL-BINARY
To install and use a MySQL binary distribution, the command sequence looks like this:
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
1)新建用户以安全方式运行进程
# groupadd -r mysql
# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
# chown -R mysql:mysql /data/mysql
2)在/usr/local/创建mysql链接
# ln -sv mysql-5.5.49 mysql
3)初始化mysql
# cd /usr/local/mysql
# chown -R root:mysql .
# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
4)mysql主配置文件
# cd /usr/local/mysql
# cp support-files/my-large.cnf  /etc/my.cnf
并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:
thread_concurrency = 2
另外还需要添加如下行指定mysql数据文件的存放位置:
datadir = /data/mysql
5)mysql提供sysv服务脚本
# cd /usr/local/mysql
# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld
添加至服务列表:
# chkconfig --add mysqld
# chkconfig mysqld on
mysql配置文件格式:片段式
配置文件的顺序,若有冲突,最后一个生效
/etc/my.cnf --> /etc/mysql/my.cnf --> $BASEDIR/my.cnf --> ~/.my.cnf
6)启动mysql
service mysqld start
7)测试httpd与mysql通信是否正常
<?php
    $connect=mysql_connect('localhost','root','');
    if ($connect)
        echo "Success...";
    else
        echo "Failed...";
?>
此处要将index,html重命名为index.php才可以正常解析php

自定义安装后需要的配置
1)建立man文件(/etc/man.config)
MANPATH /usr/local/mysql/man
2)建立库文件缓存/etc/ld.so.cache
# vim /etc/ld.so.conf.d/mysql-x86_64.conf 添加库文件路径
# ldconfig -v
3)链接头文件(最好使用绝对路径)
ln -sv /usr/local/mysql/include /usr/include/mysql
   
4)PATH
# vim /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin

说明:
MySQL服务器维护了两类变量:
    服务器变量:
        定义MySQL服务器运行特性
        SHOW GLOBAL VARIABLES [LIKE 'STRING'];
    状态变量:
        保存了MySQL服务器运行统计数据
        SHOW GLOBAL STATUS [LIKE 'STRING']
mysql> show global variables like 'socket';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| socket        | /tmp/mysql.sock |
+---------------+-----------------+
mysql> show global variables like 'datadir';
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| datadir       | /data/ |
+---------------+--------+
MySQL通配符:
    _:任意单个字符
    %:任意长度的任意字符
内置函数,user();database();version();
select version();
+------------+
| version()  |
+------------+
| 5.5.49-log |
+------------+
函数索引列表