mysql安装一 --- 源码包安装

1.登陆http://www.mysql.com/ 或者 www.oracle.com

2.

3.

4.

上面如果不能加载,禁用代理软件

5.

6.

7.

8.

9.上传

10.md5校验安装包的完整性

  1. [[email protected] ~]# md5sum ./mysql-5.6.26.tar.gz
  2. 733e1817c88c16fb193176e76f5b818f ./mysql-5.6.26.tar.gz

与上面的md5对照,如果一致说明安装包完整无缺

11.解压

  1. [[email protected] ~]# tar -xzvf mysql-5.6.26.tar.gz

源码目录说明:源码包目录.md

正式安装

1.安装cmake

下载地址:http://www.cmake.org/ 或者 http://yunpan.cn/cHgpTUaYRqjnc 访问密码 384d

  1. tar -xzvf cmake-3.3.1.tar.gz
  2. cd cmake-3.3.1
  3. ./configure
  4. make
  5. make install

需要安装gcc

yum install gcc

yum install gcc-c++

2.创建mysql安装目录和数据文件目录
  1. [[email protected] ~]# mkdir -p /usr/local/mysql
  2. [[email protected] ~]# mkdir -p /usr/local/mysql/data
3.创建用户和组
  1. groupadd mysql
  2. useradd -r -g mysql mysql
4.安装mysql
  1. tar -xzvf mysql-5.6.26.tar.gz
  2. [[email protected] ~]# cd mysql-5.6.26
  3. cmake . \
  4. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
  5. -DMYSQL_DATADIR=/usr/local/mysql/data \
  6. -DSYSCONFDIR=/etc \
  7. -DWITH_MYISAM_STORAGE_ENGINE=1 \
  8. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  9. -DWITH_MEMORY_STORAGE_ENGINE=1 \
  10. -DWITH_READLINE=1 \
  11. -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
  12. -DMYSQL_TCP_PORT=3306 \
  13. -DENABLED_LOCAL_INFILE=1 \
  14. -DWITH_PARTITION_STORAGE_ENGINE=1 \
  15. -DEXTRA_CHARSETS=all \
  16. -DDEFAULT_CHARSET=utf8 \
  17. -DDEFAULT_COLLATION=utf8_general_ci
  18. [[email protected] mysql-5.6.26]# make && make install

参数说明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录

-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录

-DDEFAULT_CHARSET=utf8     //使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci //校验字符

-DEXTRA_CHARSETS=all     //安装所有扩展字符集

-DENABLED_LOCAL_INFILE=1    //允许从本地导入数据

编译的参数可以参考http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

** 注意事项:**

重新编译时,需要清除旧的对象文件和缓存信息。

  1. # make clean
  2. # rm -f CMakeCache.txt
  3. # rm -rf /etc/my.cnf

5.配置

  1. [[email protected] ~]# chown -R mysql:mysql /usr/local/mysql
  2. [[email protected] ~]# cp mysql-5.6.26/support-files/my-small.cnf /usr/local/mysql/my.cnf
  3. 编辑my.cnf
  4. 在mysqld标签下添加如下内容:
  5. basedir=/usr/local/mysql
  6. datadir=/usr/local/mysql/data

(1)初始化配置

进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表

  1. [[email protected] ~]# cd /usr/local/mysql/
  2. [[email protected] mysql]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

(2)设置环境变量

  1. PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
  2. export PATH
  3. . .bash_profile

6.启动服务

(1)手动启动mysql服务

  1. [[email protected] rhel5~]# cd /usr/local/mysql
  2. [[email protected] rhel5 mysql]# ./bin/mysqld_safe --user=mysql &   //启动MySQL,但不能停止
  3. 启动日志写在此文件下:/usr/local/mysql/data/localhost.err
  4. [[email protected] bin]# ps -ef | grep mysql
  5. root 22979 58621 0 22:56 pts/1 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql
  6. mysql 23069 22979 0 22:56 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/db2.err --pid-file=/usr/local/mysql/data/db2.pid
  7. root 23119 58621 0 22:57 pts/1 00:00:00 grep mysql
  8. 关闭MySQL服务
  9. [[email protected] mysql]# ./bin/mysqladmin -u root -p shutdown
  10. Enter password:
  11. 150917 23:03:57 mysqld_safe mysqld from pid file /usr/local/mysql/data/db2.pid ended
  12. [1]+ Done ./bin/mysqld_safe --user=mysql  
  13. //这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。

(2)设置自动启动mysql

  1. [[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysql
  2. [[email protected] mysql]# chkconfig mysql on
  3. [[email protected] mysql]# service mysql start
  4. Starting MySQL. [ OK ]

错误

  1. [[email protected] mysql-5.6.26]# cmake .
  2. -- Running cmake version 3.3.1
  3. -- Could NOT find Git (missing: GIT_EXECUTABLE)
  4. -- MySQL 5.6.26
  5. -- Packaging as: mysql-5.6.26-Linux-i686
  6. -- Could NOT find Threads (missing: Threads_FOUND)
  7. -- Could NOT find Threads (missing: Threads_FOUND)
  8. -- Check if the system is big endian
  9. -- Searching 16 bit integer
  10. CMake Error at /usr/local/share/cmake-3.3/Modules/TestBigEndian.cmake:51 (message):
  11. no suitable type found
  12. Call Stack (most recent call first):
  13. configure.cmake:628 (TEST_BIG_ENDIAN)
  14. CMakeLists.txt:398 (INCLUDE)
  15. -- Configuring incomplete, errors occurred!
  16. See also "/root/mysql-5.6.26/CMakeFiles/CMakeOutput.log".
  17. See also "/root/mysql-5.6.26/CMakeFiles/CMakeError.log".

解决办法:

删除目录,重新解压mysql包

  1. -- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
  2. CMake Error at cmake/readline.cmake:85 (MESSAGE):
  3. Curses library not found. Please install appropriate package,
  4. remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
  5. Call Stack (most recent call first):
  6. cmake/readline.cmake:128 (FIND_CURSES)
  7. cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
  8. CMakeLists.txt:409 (MYSQL_CHECK_EDITLINE)
  9. -- Configuring incomplete, errors occurred!
  10. See also "/root/mysql-5.6.26/CMakeFiles/CMakeOutput.log".
  11. See also "/root/mysql-5.6.26/CMakeFiles/CMakeError.log".

解决:

yum install ncurses-devel

rm -rf CMakeCache.txt

重新执行

cmake .

  1. [ 50%] Building C object sql/CMakeFiles/sql.dir/__/sql-common/my_time.c.o
  2. [ 50%] Building C object sql/CMakeFiles/sql.dir/__/sql-common/my_user.c.o
  3. [ 51%] Building C object sql/CMakeFiles/sql.dir/__/sql-common/pack.c.o
  4. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/__/sql-common/client_authentication.cc.o
  5. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/event_data_objects.cc.o
  6. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/event_db_repository.cc.o
  7. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/event_parse_data.cc.o
  8. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/event_queue.cc.o
  9. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/event_scheduler.cc.o
  10. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/events.cc.o
  11. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o
  12. [ 51%] Building CXX object sql/CMakeFiles/sql.dir/sql_client.cc.o
  13. [ 51%] Linking CXX static library libsql.a
  14. /usr/bin/ar: CMakeFiles/sql.dir/rpl_handler.cc.o: No such file or directory
  15. make[2]: *** [sql/libsql.a] Error 1
  16. make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2
  17. make: *** [all] Error 2

服务启动失败:

或者

解决:

注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索”$basedir/my.cnf”,在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!

注意:在rhel 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。

在使用”yum update”更新系统后,需要检查下/etc目录下是否会多出一个my.cnf,如果多出,将它重命名成别的。否则,MySQL将使用这个配置文件启动,可能造成无法正常启动等问题。

  1. mv /etc/my.cnf /etc/my.cnf.bak

来自为知笔记(Wiz)

时间: 2025-01-20 00:15:15

mysql安装一 --- 源码包安装的相关文章

mysql 5.5源码包安装

注:由于mysql5.5的源码包安装与mysql之前的版本安装方法不同,故写一篇随笔记录.5.5的版本不再是./configure make make install 这里用到了cmake了,cmake是一个跨平台的编译工具. 注意: mysql-5.5以后的版本不能使用make编译,只能使用cmake工具编译安装. cmake指定编译选项的方式不同于make . "./configure" 与 "cmake . "相似 "./configure --he

linux下安装mysql的三种方法:rpm包安装、yum安装、源码包安装

1 安装MySQL数据库服务器安装方法一://查询系统自带的数据库rpm -qa | grep -i mysql //卸载查询到的所有mysqlrpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64rpm -e --nodeps mysql-devel-5.1.71-1.el6.x86_64rpm -e --nodeps mysql-5.1.71-1.el6.x86_64 进入rpm安装包所在文件夹,执行命令安装所有rpm包rpm -ivh *.rpm 安装

mysql源码包安装方法

mysql安装前的准备工作 环境准备:linux系统  cmake   mysql安装包 卸载掉rpm包安装的mysql Yum -y remove mysql mysql-server Rm -rf /etc/my.cnf 安装解决依赖关系:yum -y install ncurses-devel openssl-devel bison gcc gcc-c++ mysql源码包安装 将源码包上传到/usr/local/src Tar xzf mysql安装包 yum -y install cm

数据库学习之--Linux下Mysql源码包安装

数据库学习之--Linux下Mysql源码包安装 系统环境: 操作系统:RedHat EL6 DB Soft:  Mysql 5.6.4-m7     Mysql 在linux下的安装方式有两种版本,一种为Binary(二进制),另外一种为Source(源码包),本文为Source Install方式. 1.安装前的准备 解压安装包 [[email protected] ~]$ ls mysql-5.6.4-m7  mysql-5.6.4-m7.tar.gz  mysql-5.6.4-m7.ta

CentOS 6.5源码包安装MySQL

#源码包安装MySQL数据库 [[email protected] ]# yum -y install gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake bison perl curl-devel #安装MySQL [[email protected] cmake-3.0.2]# groupadd -r mysql [[email protecte

源码包安装(Python mysql redis)

一  源码包安装 (1)python3.6源码包安装 ./configure ------> 定制功能 make make install mysql 源码包 cmake make make install (2) redis 源码包安装 make 修改环境变量 vim /etc/profile 添加以下一行: export PATH=/opt/redis-3.2.10/src:$PATH 生效配置 source /etc/profile (3) 让python链接redis unzip red

zabbix源码包安装

Zabbix源码包安装 Cenos5.3 Basic server 安装顺序 Libxml2 Libmcrypt Zlib Libpng Jpeg:需要创建目录jpeg  /bin  /lib   /include   /man/man1 ./configure --prefix=/usr/local/jpeg8/ --enable-shared Freetype字体库 Libxpm安装.libXpm-devel安装 Autoconf  直接./configure装到系统里 Libgd:   [

cenos6.5源码包安装lnmp环境

虽然centos6可以用yum安装nginx,但是我还是写个教程用源码包安装用于线上环境. 一:在nginx官网下载nginx,并安装 我下载的是nginx-1.6.0 #./configure --prefix=/usr/local/nginx make&& make install 卸载已存在的apache服务和php [[email protected] Desktop]# yum remove httpd php* 安装development Tools [[email prote

编译安装MariaDB源码包

因为MySQL的发展趋势不甚乐观,MariaDB已替代MySQL被CentOS 7做为默认组件,如果想在CentOS 6中使用最新的MariaDB,则需要我们手动安装,其安装方式有三种: 1.RPM包安装 2.二进制包安装 3.源码包安装 下面我们来介绍如何使用源码包来安装MariaDB,系统平台:CentOS 6.5:MariaDB版本:10.0.19 一.获得MariaDB源码包 可以通过MariaDB的官方网站来获得MariaDB的最新源码包,下载地址为:https://downloads