mysql版本:5.6 【http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz】

        【http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz】

官方参考:http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html

安装要求:

这里提到的安装要求:

http://dev.mysql.com/doc/refman/5.6/en/source-installation.html

需要工具:CMake  http://www.cmake.org

make工具:http://www.gnu.org/software/make/   GNU make 3.75 or newer

ANSI C++ compiler:GCC 4.2.1 or later

Perl : Perl is needed if you intend to run test scripts 【option】

bison : 2.1 or newer

M4:On OpenSolaris and Solaris Express

而这里的安装要求:

http://dev.mysql.com/doc/internals/en/cmake-prerequisites.html

安装CMake的要求:

CMake:Version 2.6.3 or later    http://dev.mysql.com/doc/internals/en/cmake.html

Unix: Compiler and make utility【gcc,make】, curses dev package on Linux

All platforms: bison         http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz 

OpenSolaris/Solaris: m4       http://www.gnu.org/software/m4/

大家可以看到两个要求是一致的(废话肯定一致,两个本来说的就是一个事。只是为了避免大家迷惑才两个都拿来说)

安装mysql配置项:

http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

要注意的就是安装自己用到的字符集,data目录配置,存储引擎的支持【innodb需要明确配置,My_ISAM默认会安装】

-DWITH_INNOBASE_STORAGE_ENGINE=
-DWITH_ARCHIVE_STORAGE_ENGINE=
-DWITH_BLACKHOLE_STORAGE_ENGINE=
-DWITH_PERFSCHEMA_STORAGE_ENGINE=

字符集 可以在随便一个mysql中执行 SHOW COLLATION 语句,查看所有的。

在正式安装之前,你可能需要安装:ncurses , ncurses-devel

上面有ncurse包:
[root@host ncurse]#./configure
[root@host ncurse]#make&&make install

正式安装:

    tar zxvf mysql-5.6..tar.gz
ls
cd mysql-5.6.
ls
groupadd mysql
useradd -r -g mysql mysql
cmake .
make
cmake --help
make clean
rm CMakeCache.txt
make install
cd /usr/local/mysql/
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
bin/mysqld_safe --user=mysql &
/usr/local/mysql/bin/mysql -uroot -p
ls /tmp/
ls /tmp/mysql.sock
bin/mysqld_safe --user=mysql &
netstat -an |grep
ps aux |grep mysql
bin/mysqld_safe --user=mysql &
less /var/log/mysqld.log
mkdir /var/run/mysqld
chown -R mysql /var/run/mysqld
bin/mysqld_safe --user=mysql &
bin/mysql -uroot -p
ps aux |grep mysql
netstat -an |grep
bin/mysql -uroot -p
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
bin/mysql -uroot -p
cp /usr/local/mysql/support-files/mysql.serve /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level mysqld on
service mysqld stop
service mysqld restart
pkill mysql
service mysqld restart
bin/mysql -uroot -p
halt
service mysqld start

安装完成。

中间遇到的问题:

安装完成后mysql启动不了:

启动mysql时报错:

Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
:: mysqld ended
查看日志:
#less /var/log/mysqld.log
其中有一段如下: :: [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
:: [ERROR] Can't start server: can't create PID file: No such file or directory
:: mysqld ended
#cd /var/run/
#ls

mysqld目录不存在,创建。

374 mkdir /var/run/mysqld
375 chown -R mysql /var/run/mysqld

可以正常启动了,但是用客户端连接mysqld 又错:

[root@localhost mysql]# bin/mysqladmin -u root password root
bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' ()'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
[root@localhost mysql]# bin/mysql -u root -p
Enter password:
ERROR (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
分析:是/tmp/mysql.sock 不存在

由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,创建符号连接:

382  ln -s /var/lib/mysql/mysql.sock  /tmp/mysql.sock

再重启,可以了。

如果第一次cmake有问题,需要二次cmake,记得将CMakeCache.txt清理掉,否则新的cmake会不起作用。

 #!/bin/sh
# Copyright Abandoned TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind # MySQL daemon start/stop script. # Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down. # Comments to support chkconfig on RedHat Linux
# chkconfig:
# description: A very fast and reliable SQL database engine. # Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:
# Default-Stop:
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO # If you install MySQL on some other places than /usr/local/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
# [mysqld]
# basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
# and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
# below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. # If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files. basedir=
datadir= # Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout= # Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql" # The following variables are only set for letting mysql.server find things. # Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=/usr/local/mysql/data
fi
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi # datadir_set is used to determine if datadir was set (and so should be
# *not* set inside of the --basedir= handler.)
datadir_set= #
# Use LSB init script functions for printing messages, if possible
#
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
log_success_msg()
{
echo " SUCCESS! $@"
}
log_failure_msg()
{
echo " ERROR! $@"
}
fi PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
export PATH mode=$ # start or stop [ $# -ge ] && shift other_args="$*" # uncommon, but needed when called from an RPM upgrade action
# Expected: "--skip-networking --skip-grant-tables"
# They are not checked here, intentionally, as it is the resposibility
# of the "spec" file author to give correct arguments only. case `echo "testing\c"`,`echo -n testing` in
*c*,-n*) echo_n= echo_c= ;;
*c*,*) echo_n=-n echo_c= ;;
*) echo_n= echo_c='\c' ;;
esac parse_server_arguments() {
for arg do
case "$arg" in
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'`
bindir="$basedir/bin"
if test -z "$datadir_set"; then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
;;
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
datadir_set=
;;
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
esac
done
} wait_for_pid () {
verb="$1" # created | removed
pid="$2" # process ID of the program operating on the pid-file
pid_file_path="$3" # path to the PID file. i=
avoid_race_condition="by checking again" while test $i -ne $service_startup_timeout ; do case "$verb" in
'created')
# wait for a PID-file to pop into existence.
test -s "$pid_file_path" && i='' && break
;;
'removed')
# wait for this PID-file to disappear
test ! -s "$pid_file_path" && i='' && break
;;
*)
echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
exit
;;
esac # if server isn't running, then pid-file will never be updated
if test -n "$pid"; then
if kill - "$pid" >/dev/null; then
: # the server still runs
else
# The server may have exited between the last pid-file check and now.
if test -n "$avoid_race_condition"; then
avoid_race_condition=""
continue # Check again.
fi # there's nothing that will affect the file.
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
return # not waiting any more.
fi
fi echo $echo_n ".$echo_c"
i=`expr $i + `
sleep done if test -z "$i" ; then
log_success_msg
return
else
log_failure_msg
return
fi
} # Get arguments from the my.cnf file,
# the only group, which is read from now on is [mysqld]
if test -x ./bin/my_print_defaults
then
print_defaults="./bin/my_print_defaults"
elif test -x $bindir/my_print_defaults
then
print_defaults="$bindir/my_print_defaults"
elif test -x $bindir/mysql_print_defaults
then
print_defaults="$bindir/mysql_print_defaults"
else
# Try to find basedir in /etc/my.cnf
conf=/etc/my.cnf
print_defaults=
if test -r $conf
then
subpat='^[^=]*basedir[^=]*=\(.*\)$'
dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
for d in $dirs
do
d=`echo $d | sed -e 's/[ ]//g'`
if test -x "$d/bin/my_print_defaults"
then
print_defaults="$d/bin/my_print_defaults"
break
fi
if test -x "$d/bin/mysql_print_defaults"
then
print_defaults="$d/bin/mysql_print_defaults"
break
fi
done
fi # Hope it's in the PATH ... but I doubt it
test -z "$print_defaults" && print_defaults="my_print_defaults"
fi #
# Read defaults file from 'basedir'. If there is no defaults file there
# check if it's in the old (depricated) place (datadir) and read it from there
# extra_args=""
if test -r "$basedir/my.cnf"
then
extra_args="-e $basedir/my.cnf"
else
if test -r "$datadir/my.cnf"
then
extra_args="-e $datadir/my.cnf"
fi
fi parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` #
# Set pid file if not given
#
if test -z "$mysqld_pid_file_path"
then
mysqld_pid_file_path=$datadir/`hostname`.pid
else
case "$mysqld_pid_file_path" in
/* ) ;;
* ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
esac
fi case "$mode" in
'start')
# Start daemon # Safeguard (relative paths, core dumps..)
cd $basedir echo $echo_n "Starting MySQL"
if test -x $bindir/mysqld_safe
then
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? # Make lock for RedHat / SuSE
if test -w "$lockdir"
then
touch "$lock_file_path"
fi exit $return_value
else
log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
fi
;; 'stop')
# Stop daemon. We use a signal here to avoid having to know the
# root password. if test -s "$mysqld_pid_file_path"
then
mysqld_pid=`cat "$mysqld_pid_file_path"` if (kill -0 $mysqld_pid 2>/dev/null)
then
echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
# mysqld should remove the pid file when it exits, so wait for it.
wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
else
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
rm "$mysqld_pid_file_path"
fi # Delete lock for RedHat / SuSE
if test -f "$lock_file_path"
then
rm -f "$lock_file_path"
fi
exit $return_value
else
log_failure_msg "MySQL server PID file could not be found!"
fi
;; 'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
if $0 stop $other_args; then
$0 start $other_args
else
log_failure_msg "Failed to stop running server, so refusing to try to start."
exit 1
fi
;; 'reload'|'force-reload')
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
touch "$mysqld_pid_file_path"
else
log_failure_msg "MySQL PID file could not be found!"
exit 1
fi
;;
'status')
# First, check to see if pid file exists
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
if kill -0 $mysqld_pid 2>/dev/null ; then
log_success_msg "MySQL running ($mysqld_pid)"
exit 0
else
log_failure_msg "MySQL is not running, but PID file exists"
exit 1
fi
else
# Try to find appropriate mysqld process
mysqld_pid=`pidof $libexecdir/mysqld` # test if multiple pids exist
pid_count=`echo $mysqld_pid | wc -w`
if test $pid_count -gt 1 ; then
log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
exit 5
elif test -z $mysqld_pid ; then
if test -f "$lock_file_path" ; then
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
exit 2
fi
log_failure_msg "MySQL is not running"
exit 3
else
log_failure_msg "MySQL is running but PID file could not be found"
exit 4
fi
fi
;;
*)
# usage
basename=`basename "$0"`
echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]"
exit 1
;;
esac exit 0

mysqld加入服务的脚本

参考:

http://blog.csdn.net/itchiang/article/details/9012493

跟两个无关的yum配置连接,我中间做其他事情用到了。

http://www.cnblogs.com/shuaixf/archive/2011/11/30/2268496.html
http://blog.chinaunix.net/uid-26683523-id-3074744.html

lnmp环境的操作部分:

安装php+nginx:http://www.cnblogs.com/simpman/p/4151662.html

安装mysql:http://www.cnblogs.com/simpman/p/4192942.html

安装php:http://www.cnblogs.com/simpman/p/4196051.html

lnmp环境的理论部分:

FastCgi与PHP-fpm关系[转] 读完本文瞬间明朗了很多 : http://www.cnblogs.com/simpman/p/4151639.html

epoll和select区别:http://www.cnblogs.com/simpman/p/4150005.html

lnmp安装--linux通过tar.gz源码包安装mysql的更多相关文章

  1. Linux 系统下用源码包安装软件

    Linux系统下用源码包安装软件 by:授客 QQ:1033553122 下载源码安装包,解压或者直接双击打开(如果有安装zip或rar等压缩/解压缩软件的话),查找相关的安装说明文件,一般是READ ...

  2. Linux yum源码包安装和卸载

    Linux 下的绝大多数源码包都是用 C 语言编写的,还有少部分是用 C++ 等其他程序语言编写的.所以,要想安装源码包,必须安装 C 语言编译器 gcc(如果是用 C++ 编写的程序,则还需要安装 ...

  3. Linux之源码包安装软件

    安装准备      安装c语言编辑器 gcc      压缩包  node-v6.2.0-linux-x64.tar.gz   源码包保存位置  /usr/local/src/ 源码包安装位置 /us ...

  4. 基于LNMP的Zabbbix之Zabbix Agent源码详细安装,但不给图

    基于LNMP的Zabbbix之Zabbix Server源码详细安装:http://www.cnblogs.com/losbyday/p/5828547.html wget http://jaist. ...

  5. Linux源码包安装过程及注意事项

    众做周知RedHat Linux使用RPM包管理器安装rpm包,但是RPM包是由红帽编译打包的,通常相对于最新版落后了很多,甚至可能缺少我们所要使用的功能.如果你需要定制想要的软件功能.自定义安装路径 ...

  6. Linux进阶之Linux破解密码、yum源配置、防火墙设置及源码包安装

    一.老师语录: 所有要求笔试的公司都是垃圾公司 笔试(是考所有的涉及到的点) 要有自己的卖点.专长(给自己个标签)(至少一个) 生产环境中,尽量使用mv(mv到一个没用的目录下),少使用rm 二.防火 ...

  7. Linux学习(二十)软件安装与卸载(三)源码包安装

    一.概述 源码包安装的优点在于它自由程度比较高,可以指定目录与组件.再有,你要是能改源码也可以. 二.安装方法 步骤 1.从官网或者信任站点下载源码包 [root@localhost ~]# wget ...

  8. Linux源码包安装程序

    ★安装OS时,建议提前安装开发组件 CentOS 6:Development Tools.Server Platform DevelopmentCentOS 7:Development Tools.D ...

  9. linux 软件包安装方式选择、安装位置、源码包安装

    对外提供服务,比如apache,应使用源码包安装对内提供服务,比如gcc,只是我自己使用,使用rpm包安装 rpm包不需要指定安装位置,源码包的安装需要手动指定安装位置 rpm包默认安装位置/etc/ ...

随机推荐

  1. C++_快速排序

    void quick_sort(int s[],int l,int r) { if(l<r) { int i=l,j=r,x=s[l]; while(i<j) { while( i< ...

  2. Mysql中自增字段(AUTO_INCREMENT)的一些常识

    Mysql中自增字段(AUTO_INCREMENT)的一些常识: http://chengxuyuan.naxieshir.com/fenlei/2/p/151.html

  3. 1002 GTY's birthday gift

    GTY's birthday gift                                                                       Time Limit ...

  4. css笔记15:盒子模型

    1.流 流:html元素在网页中显示的顺序 标准流:在html文件中,写在前面的元素在前面显示,写在后面的html元素在后面显示. 非标准流:在html之中,当某个元素脱离了标准流,那么它处于非标准流 ...

  5. IE8 innerHTML赋值时包含多级HTML标签时的解决方案

    var inhtml = ''; var font = document.createElement("font"); var a = document.createElement ...

  6. CF Anya and Ghosts (贪心)

    Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  7. Linux中ifcfg-eth0配置参数解释

    Linux中设置IP地址经常使用到ifcfg-eth0这个文件.  vi /etc/sysconfig/network-scripts/ifcfg-eth0 附录文件中的内容: DEVICE=eth0 ...

  8. web-app1--移动端等比例代码

    1  :   <meat name="viewport" content="width=device-width,initial-scale=1"/> ...

  9. 整合Spring与Hibernate

    在学习spring的时候,要整合hibernate,本来是看起来挺简单的,但是遇到的远要比想到了多,而且多很多,期间几天一个bug实在难调,几度放弃,但终究柳暗花明,抑制不住喜悦就想着分享一下成果吧. ...

  10. %r与%s的区别

    %r用rper()方法处理对象 %s用str()方法处理对象 有些情况下,两者处理的结果是一样的,比如说处理int型对象. 例一: print "I am %d years old.&quo ...