1.mysql source code install(5.7.15)
mysql版本相关知识
mysql的命名机制使用3个数字和一个后最组成的版本号
mysql-5.0.0-beta 5表示主版本号,0表示级别,9表示发行系列的版本号
alpha -有未被测试的新代码
beta -alpha版使用一个月之后没有致命漏洞
rc -发行了一段时间的beta版本
GA -稳定版本
mysql源码目录
BUILD:各种平台的编译脚本,检测cpu型号
client:客户端程序的源代码
Docs:文档目录
storage:存储引擎目录
sql :数据库主程序目录
mysys :mysql为了实现跨平台
./configure -检测系统是否有CC&GCC,生成makefile,
控制mysql的编译动作,是一个shell脚本。
有很多参数供选择,具体查看帮助
-prefix -设定安装路径,默认为“/usr/local"
-datadir -设置mysql数据文件存放路径
-with-charset -设定系统的默认字符集
-with-collation -系统默认的校验规则
-with-extra-charsets -除了默认字符集外需要编译安装的字符集
-with-unix-socket-path -设定socket文件地址
-with-tcp-port -指定特定监听端口,默认为3306
-with-mysqld-user -指定运行mysqld的os的用户,默认为mysql
-without-query-cache -禁用query cache功能
-without-innodb -禁用innodb存储引擎
--with-partition -5.1版本中开启partition特性
--enable-thread-safe-client -以线程方式编译客户端
-with-pthread -强制使用pthread线程库编译
-with-named-thread-libs -指定使用某个特定的线程库编译
-without-debug -使用非debug模式
-with-mysqld-ldflags -mysqld的额外link参数
-with-client-ldflags -client的额外link参数
1.安装依赖包
[root@bruce yum.repos.d]# yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison
2.建立mysql用户
[root@bruce u03]# useradd mysql -d /u03/mysql
3.安装mysql
[root@bruce u03]# ll mysql-5.7.15.tar.gz
-rwxr-xr-x 1 root root 50539618 Oct 12 15:04 mysql-5.7.15.tar.gz
[root@bruce u03]# tar -zxvf mysql-5.7.15.tar.gz
[root@bruce u03]# ll
drwxr-xr-x 35 7161 31415 4096 Aug 25 20:00 mysql-5.7.15
-rwxr-xr-x 1 root root 50539618 Oct 12 15:04 mysql-5.7.15.tar.gz
[root@bruce u03]# cd mysql-5.7.15
[root@bruce mysql-5.7.15]# cmake -DCMAKE_INSTALL_PREFIX=/u03/mysql -DMYSQL_DATADIR=/u03/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
CMake Error at CMakeLists.txt:21 (CMAKE_MINIMUM_REQUIRED):
CMake 2.8.2 or higher is required. You are running version 2.6.4
-- Configuring incomplete, errors occurred!
cmake版本太低
下载一个高版本的吧
4.安装cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz (这个直接下载有问题,还是直接firefox下载吧)
[root@bruce u03]# tar -zxvf cmake-2.8.5.tar.gz
[root@bruce u03]# cd cmake-2.8.5
[root@bruce cmake-2.8.5]# ./configure
[root@bruce cmake-2.8.5]# make
[root@bruce cmake-2.8.5]# make install
5.install mysql
[root@bruce mysql-5.7.15]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/u03/mysql -DMYSQL_DATADIR=/u03/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
-- Running cmake version 2.8.5
-- Configuring with MAX_INDEXES = 64U
-- SIZEOF_VOIDP 8
-- MySQL 5.7.15
-- Packaging as: mysql-5.7.15-Linux-x86_64
-- Downloading boost_1_59_0.tar.gz to /usr/local/boost
-- [download 100% complete]
-- Download failed, error: 1;"unsupported protocol"
CMake Error at cmake/boost.cmake:194 (MESSAGE):
You can try downloading
http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
manually using curl/wget or a similar tool
Call Stack (most recent call first):
CMakeLists.txt:455 (INCLUDE)
-- Configuring incomplete, errors occurred!
还是有问题。要安装boost库
6.安装boost库
[root@bruce u03]# wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
[root@bruce u03]# ll boost_1_59_0.tar.gz
-rwxr-xr-x 1 root root 83709983 Oct 16 14:32 boost_1_59_0.tar.gz
[root@bruce u03]# tar -zxvf boost_1_59_0.tar.gz
[root@bruce u03]# mv boost_1_59_0 /usr/local/boost
7.mysql安装
[root@bruce u03]# cd mysql-5.7.15
[root@bruce mysql-5.7.15]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/u03/mysql -DMYSQL_DATADIR=/u03/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
[root@bruce mysql-5.7.15]# make
[root@bruce mysql-5.7.15]# make install
8.初始化mysql
[root@bruce bin]# /u03/mysql/bin/mysqld --initialize --user=mysql --basedir=/u03/mysql --datadir=/u03/mysql/data
##2016-10-16T07:20:31.918992Z 1 [Note] A temporary password is generated for root@localhost: 1ekxd;(;9ziK #初始化后会生成默认密码
9.调整配置文件
[root@bruce ~]# mv /etc/my.cnf /etc/my.cnf.bak
[root@bruce ~]# cp /u03/mysql/support-files/my-default.cnf /etc/my.cnf
/etc/my.cnf加入了三个参数
basedir = /u03/mysql
datadir = /u03/mysql/data
port = 3306
10.启动mysql
[root@bruce ~]# /u03/mysql/bin/mysqld_safe &
[1] 10129
[root@bruce ~]# 2016-10-16T07:25:21.239091Z mysqld_safe Logging to '/u03/mysql/data/bruce.err'.
2016-10-16T07:25:21.382437Z mysqld_safe Starting mysqld daemon with databases from /u03/mysql/data
[root@bruce ~]# ps -ef | grep mysql
root 10129 13805 0 15:25 pts/1 00:00:00 /bin/sh /u03/mysql/bin/mysqld_safe
mysql 10254 10129 3 15:25 pts/1 00:00:00 /u03/mysql/bin/mysqld --basedir=/u03/mysql --datadir=/u03/mysql/data --plugin-dir=/u03/mysql/lib/plugin --user=mysql --log-error=/u03/mysql/data/bruce.err --pid-file=/u03/mysql/data/bruce.pid --port=3306
root 10285 13805 0 15:25 pts/1 00:00:00 grep mysql
11.访问数据库
刚开始的时候登录不了数据库,在/etc/my.cnf中加入了skip-grant-tables参数,使登录时密码为空.
然后执行了如下语句.
update user set authentication_string=password("mysql") where user="root";
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
这个错误需要执行如下操作.
update user set password_expired="N" where user="root";
完成后注释掉/etc/my.cnf文件中的skip-grant-tables参数
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-2147635/ ,如需转载,请注明出处,否则将追究法律责任。