데이터 베이스 MySQL 튜토리얼 源码编译安装MySQL5.6.12详细过程_MySQL

源码编译安装MySQL5.6.12详细过程_MySQL

May 31, 2016 am 08:50 AM

1 下载安装包download tar.gz

wget http://download.csdn.net/detail/mchdba/7545037

2 安装cmake软件包

yum install cmake -y

3 create account of mysql

groupadd mysql           

useradd -g mysql mysql           

autoreconf --force --install

libtoolize --automake --force

automake --force --add-missing

4  complie the sources

数据目录  : /home/data/mysql/data

mysql软件目录  : /usr/local/mysql

mkdir -p /home/data/mysql/data

mkdir -p /usr/local/mysql

tar -xvf mysql-5.6.12.tar.gz 

cd mysql-5.6.12

5 预编译

[root@squid-2 mysql-5.6.12]# time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/data/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

......

-- Check size of wint_t

-- Check size of wint_t - done

-- Could NOT find Curses  (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:85 (MESSAGE):

  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

Call Stack (most recent call first):

  cmake/readline.cmake:128 (FIND_CURSES)

  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)

  CMakeLists.txt:325 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!

real 0m41.872s

user 0m23.508s

sys 0m16.328s

6 yum install make

ok

[root@472322 mysql-5.6.13]# 

[解决]

删除txt

[root@squid-2 mysql-5.6.12]# find / -name CMakeCache.txt

/root/mysql/mysql-5.6.12/CMakeCache.txt

安装ncurses-devel

yum -y install ncurses-devel

再报错如下:

-- Performing Test HAVE_PEERCRED

CMake Error at /usr/share/cmake/Modules/CMakeCXXInformation.cmake:17 (GET_FILENAME_COMPONENT):

  get_filename_component called with incorrect number of arguments

Call Stack (most recent call first):

  CMakeLists.txt:3 (PROJECT)

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

CMake Error: Internal CMake error, TryCompile configure of cmake failed

-- Performing Test HAVE_PEERCRED - Failed

-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl

-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.

-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80

Warning: Bison executable not found in PATH

-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl

-- Configuring incomplete, errors occurred!

real 0m42.841s

user 0m24.527s

sys 0m16.543s

-- Configuring incomplete, errors occurred!

real    0m0.510s

user    0m0.275s

sys     0m0.112s

[root@472322 mysql-5.6.13]# 

yum install gcc gcc-c++ -y

    yum install -y ncurses-devel.x86_64

    yum install -y cmake.x86_64

    yum install -y libaio.x86_64

    yum install -y bison.x86_64

yum install -y gcc-c++.x86_64

[解决办法]:删除原来的mysql-5.6.12目录,重新解压缩tar.gz包

8 重新执行编译

rm -rf /root/mysql-5.6.12

cd /root/

tar -xvf mysql-5.6.12.tar.gz 

cd /root/mysql-5.6.12

time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/data/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

......

-- Looking for asprintf - found

-- Check size of pthread_t

-- Check size of pthread_t - done

-- Using cmake version 2.6.4

-- Not building NDB

-- Performing Test HAVE_PEERCRED

-- Performing Test HAVE_PEERCRED - Success

-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl

-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.

-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80

-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl

-- Configuring done

-- Generating done

-- Build files have been written to: /root/mysql/mysql-5.6.12

real 0m45.943s

user 0m26.213s

sys 0m17.661s

time make 

这一步时间比较长,需要耐心等待,看中间是否有error信息产生。

会看到很多Building信息

......

[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0iter.cc.o

[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0lock.cc.o

[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0wait.cc.o

[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/log/log0log.cc.o

[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/log/log0recv.cc.o

[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/mach/mach0data.cc.o

[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/mem/mem0mem.cc.o

......

[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o

Linking CXX executable my_safe_process

[100%] Built target my_safe_process

real 21m39.375s

user 18m9.239s

sys 1m34.320s

time make install

这个命令比较快

......

-- Installing: /usr/local/mysql/man/man8/mysqld.8

-- Installing: /usr/local/mysql/support-files/solaris/postinstall-solaris

real 0m8.439s

user 0m3.353s

sys 0m4.616s

9 init db,初始化数据库

ll /home/data/mysql/data

cd /home/data/mysql/data

先赋予文件夹mysql权限

chown -R mysql /home/data/mysql/data

chgrp -R mysql /home/data/mysql/data

chown -R mysql /usr/local/mysql/

chgrp -R mysql /usr/local/mysql/

cd /usr/local/mysql/

cp support-files/my-default.cnf /etc/my56.cnf

scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/usr/local/mysql/my.cnf

[root@localhost mysql]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/usr/local/mysql/my.cnf

Installing MySQL system tables.../usr/local/mysql/bin/mysqld: File '/home/data/mysql/binlog/mysql-bin.index' not found (Errcode: 2 - No such file or directory)

2014-06-27 10:47:14 9686 [ERROR] Aborting

2014-06-27 10:47:14 9686 [Note] Binlog end

2014-06-27 10:47:14 9686 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

[root@localhost mysql]# mkdir -p /home/data/mysql/binlog/

[root@localhost mysql]#

[root@localhost mysql]# chown -R mysql /home/data/mysql/binlog/

[root@localhost mysql]# chgrp -R mysql /home/data/mysql/binlog/

建好目录,再执行数据库初始化:

[root@472322 mysql56]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/usr/local/mysql/my.cnf

Installing MySQL system tables...2013-08-22 05:06:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2013-08-22 05:06:03 19416 [Note] InnoDB: The InnoDB memory heap is disabled

2013-08-22 05:06:03 19416 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2013-08-22 05:06:03 19416 [Note] InnoDB: Compressed tables use zlib 1.2.3

2013-08-22 05:06:03 19416 [Note] InnoDB: Using CPU crc32 instructions

2013-08-22 05:06:03 19416 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2013-08-22 05:06:03 19416 [Note] InnoDB: Completed initialization of buffer pool

2013-08-22 05:06:03 19416 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2013-08-22 05:06:03 19416 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2013-08-22 05:06:03 19416 [Note] InnoDB: Database physically writes the file full: wait...

2013-08-22 05:06:03 19416 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2013-08-22 05:06:03 19416 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2013-08-22 05:06:03 19416 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2013-08-22 05:06:03 19416 [Warning] InnoDB: New log files created, LSN=45781

2013-08-22 05:06:03 19416 [Note] InnoDB: Doublewrite buffer not found: creating new

2013-08-22 05:06:03 19416 [Note] InnoDB: Doublewrite buffer created

2013-08-22 05:06:03 19416 [Note] InnoDB: 128 rollback segment(s) are active.

2013-08-22 05:06:03 19416 [Warning] InnoDB: Creating foreign key constraint system tables.

2013-08-22 05:06:03 19416 [Note] InnoDB: Foreign key constraint system tables created

2013-08-22 05:06:03 19416 [Note] InnoDB: Creating tablespace and datafile system tables.

2013-08-22 05:06:03 19416 [Note] InnoDB: Tablespace and datafile system tables created.

2013-08-22 05:06:03 19416 [Note] InnoDB: Waiting for purge to start

2013-08-22 05:06:03 19416 [Note] InnoDB: 5.6.13 started; log sequence number 0

2013-08-22 05:06:04 19416 [Note] Binlog end

2013-08-22 05:06:04 19416 [Note] InnoDB: FTS optimize thread exiting.

2013-08-22 05:06:04 19416 [Note] InnoDB: Starting shutdown...

2013-08-22 05:06:05 19416 [Note] InnoDB: Shutdown completed; log sequence number 1625977

OK

Filling help tables...2013-08-22 05:06:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2013-08-22 05:06:05 19439 [Note] InnoDB: The InnoDB memory heap is disabled

2013-08-22 05:06:05 19439 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2013-08-22 05:06:05 19439 [Note] InnoDB: Compressed tables use zlib 1.2.3

2013-08-22 05:06:05 19439 [Note] InnoDB: Using CPU crc32 instructions

2013-08-22 05:06:05 19439 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2013-08-22 05:06:05 19439 [Note] InnoDB: Completed initialization of buffer pool

2013-08-22 05:06:05 19439 [Note] InnoDB: Highest supported file format is Barracuda.

2013-08-22 05:06:05 19439 [Note] InnoDB: 128 rollback segment(s) are active.

2013-08-22 05:06:05 19439 [Note] InnoDB: Waiting for purge to start

2013-08-22 05:06:05 19439 [Note] InnoDB: 5.6.13 started; log sequence number 1625977

2013-08-22 05:06:05 19439 [Note] Binlog end

2013-08-22 05:06:05 19439 [Note] InnoDB: FTS optimize thread exiting.

2013-08-22 05:06:05 19439 [Note] InnoDB: Starting shutdown...

2013-08-22 05:06:06 19439 [Note] InnoDB: Shutdown completed; log sequence number 1625987

OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

  /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'

  /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password 'new-password'

Alternatively you can run:

  /usr/local/mysql56/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql56/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/local/mysql56/my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

--defaults-file argument to mysqld_safe when starting the server

[root@472322 mysql56]# 

10 copy start command 

cp support-files/mysql.server /etc/init.d/mysqld5612

chmod 700 /etc/init.d/mysqld5612

echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile 

source /etc/profile

11 添加开机启动

chkconfig --add mysqld5612

12  start service 

service mysqld5612 start

[root@squid-2 mysql]# service mysqld5612 start

Starting MySQL.......The server quit without updating PID f[失败]usr/local/mysql/mysqld.pid).

[root@squid-2 mysql]# 

查看日志报错如下:

2014-06-24 14:56:54 31726 [Note] Server socket created on IP: '::'.

2014-06-24 14:56:54 31726 [ERROR] Can't start server : Bind on unix socket: Permission denied

2014-06-24 14:56:54 31726 [ERROR] Do you already have another mysqld server running on socket: /usr/local/mysql/mysql.sock ?

2014-06-24 14:56:54 31726 [ERROR] Aborting

解决原因是:

/usr/local/mysql跟目录需要赋予mysql权限

根据日志文件显示,首先检查运行权限,再看一下/usr/local/mysql/mysql.sock,发现/usr/local/mysql目录下并没有该文件,是否是没有权限写目录?

看到/usr/local/mysql目录是root用户,所以赋予mysql操作权限。

chown -R mysql.mysql /usr/local/mysql

 

[root@472322 data56]# service mysqld5612 start

Starting MySQL. SUCCESS! 

[root@472322 data56]# mysql

Welcome to the MySQL monitor.  Commands end with ; or /g.

Your MySQL connection id is 1

Server version: 5.6.13 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> 

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

MySQL에서 인덱스를 사용하는 것보다 전체 테이블 스캔이 더 빠를 수 있습니까? MySQL에서 인덱스를 사용하는 것보다 전체 테이블 스캔이 더 빠를 수 있습니까? Apr 09, 2025 am 12:05 AM

전체 테이블 스캔은 MySQL에서 인덱스를 사용하는 것보다 빠를 수 있습니다. 특정 사례는 다음과 같습니다. 1) 데이터 볼륨은 작습니다. 2) 쿼리가 많은 양의 데이터를 반환 할 때; 3) 인덱스 열이 매우 선택적이지 않은 경우; 4) 복잡한 쿼리시. 쿼리 계획을 분석하고 인덱스 최적화, 과도한 인덱스를 피하고 정기적으로 테이블을 유지 관리하면 실제 응용 프로그램에서 최상의 선택을 할 수 있습니다.

Windows 7에 MySQL을 설치할 수 있습니까? Windows 7에 MySQL을 설치할 수 있습니까? Apr 08, 2025 pm 03:21 PM

예, MySQL은 Windows 7에 설치 될 수 있으며 Microsoft는 Windows 7 지원을 중단했지만 MySQL은 여전히 ​​호환됩니다. 그러나 설치 프로세스 중에 다음 지점이 표시되어야합니다. Windows 용 MySQL 설치 프로그램을 다운로드하십시오. MySQL의 적절한 버전 (커뮤니티 또는 기업)을 선택하십시오. 설치 프로세스 중에 적절한 설치 디렉토리 및 문자를 선택하십시오. 루트 사용자 비밀번호를 설정하고 올바르게 유지하십시오. 테스트를 위해 데이터베이스에 연결하십시오. Windows 7의 호환성 및 보안 문제에 주목하고 지원되는 운영 체제로 업그레이드하는 것이 좋습니다.

InnoDB 전체 텍스트 검색 기능을 설명하십시오. InnoDB 전체 텍스트 검색 기능을 설명하십시오. Apr 02, 2025 pm 06:09 PM

InnoDB의 전체 텍스트 검색 기능은 매우 강력하여 데이터베이스 쿼리 효율성과 대량의 텍스트 데이터를 처리 할 수있는 능력을 크게 향상시킬 수 있습니다. 1) InnoDB는 기본 및 고급 검색 쿼리를 지원하는 역 색인화를 통해 전체 텍스트 검색을 구현합니다. 2) 매치 및 키워드를 사용하여 검색, 부울 모드 및 문구 검색을 지원합니다. 3) 최적화 방법에는 워드 세분화 기술 사용, 인덱스의 주기적 재건 및 캐시 크기 조정, 성능과 정확도를 향상시키는 것이 포함됩니다.

InnoDB에서 클러스터 된 인덱스와 비 클러스터 된 인덱스 (2 차 지수)의 차이. InnoDB에서 클러스터 된 인덱스와 비 클러스터 된 인덱스 (2 차 지수)의 차이. Apr 02, 2025 pm 06:25 PM

클러스터 인덱스와 비 클러스터 인덱스의 차이점은 1. 클러스터 된 인덱스는 인덱스 구조에 데이터 행을 저장하며, 이는 기본 키 및 범위별로 쿼리에 적합합니다. 2. 클러스터되지 않은 인덱스는 인덱스 키 값과 포인터를 데이터 행으로 저장하며 비 예산 키 열 쿼리에 적합합니다.

MySQL : 쉽게 학습하기위한 간단한 개념 MySQL : 쉽게 학습하기위한 간단한 개념 Apr 10, 2025 am 09:29 AM

MySQL은 오픈 소스 관계형 데이터베이스 관리 시스템입니다. 1) 데이터베이스 및 테이블 작성 : CreateAbase 및 CreateTable 명령을 사용하십시오. 2) 기본 작업 : 삽입, 업데이트, 삭제 및 선택. 3) 고급 운영 : 가입, 하위 쿼리 및 거래 처리. 4) 디버깅 기술 : 확인, 데이터 유형 및 권한을 확인하십시오. 5) 최적화 제안 : 인덱스 사용, 선택을 피하고 거래를 사용하십시오.

다양한 유형의 MySQL 인덱스 (B-Tree, Hash, Full-Text, Spatial)를 설명하십시오. 다양한 유형의 MySQL 인덱스 (B-Tree, Hash, Full-Text, Spatial)를 설명하십시오. Apr 02, 2025 pm 07:05 PM

MySQL은 B-Tree, Hash, Full-Text 및 Spatial의 4 가지 인덱스 유형을 지원합니다. 1.B- 트리 색인은 동일한 값 검색, 범위 쿼리 및 정렬에 적합합니다. 2. 해시 인덱스는 동일한 값 검색에 적합하지만 범위 쿼리 및 정렬을 지원하지 않습니다. 3. 전체 텍스트 색인은 전체 텍스트 검색에 사용되며 다량의 텍스트 데이터를 처리하는 데 적합합니다. 4. 공간 지수는 지리 공간 데이터 쿼리에 사용되며 GIS 응용 프로그램에 적합합니다.

MySQL 사용자와 데이터베이스의 관계 MySQL 사용자와 데이터베이스의 관계 Apr 08, 2025 pm 07:15 PM

MySQL 데이터베이스에서 사용자와 데이터베이스 간의 관계는 권한과 테이블로 정의됩니다. 사용자는 데이터베이스에 액세스 할 수있는 사용자 이름과 비밀번호가 있습니다. 권한은 보조금 명령을 통해 부여되며 테이블은 Create Table 명령에 의해 생성됩니다. 사용자와 데이터베이스 간의 관계를 설정하려면 데이터베이스를 작성하고 사용자를 생성 한 다음 권한을 부여해야합니다.

MySQL과 Mariadb가 공존 할 수 있습니다 MySQL과 Mariadb가 공존 할 수 있습니다 Apr 08, 2025 pm 02:27 PM

MySQL 및 MariaDB는 공존 할 수 있지만주의해서 구성해야합니다. 열쇠는 각 데이터베이스에 다른 포트 번호와 데이터 디렉토리를 할당하고 메모리 할당 및 캐시 크기와 같은 매개 변수를 조정하는 것입니다. 연결 풀링, 애플리케이션 구성 및 버전 차이도 고려해야하며 함정을 피하기 위해 신중하게 테스트하고 계획해야합니다. 두 개의 데이터베이스를 동시에 실행하면 리소스가 제한되는 상황에서 성능 문제가 발생할 수 있습니다.

See all articles