Red Hat5下源码安装mysql5.6过程记录

1.安装cmake包

[[email protected] soft]# tar -xzf cmake-3.0.0.tar.Z
[[email protected] soft]# cd cmake-3.0.0
[[email protected] cmake-3.0.0]# ./configure   #对包进行初始化配置
......
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for wsyncup in /usr/lib/libcurses.so
-- Looking for wsyncup in /usr/lib/libcurses.so - found
-- Looking for cbreak in /usr/lib/libncurses.so
-- Looking for cbreak in /usr/lib/libncurses.so - found
-- Looking for elf.h
-- Looking for elf.h - found
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - /usr/bin/f95
-- Performing Test run_pic_test
-- Performing Test run_pic_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /root/soft/cmake-3.0.0
---------------------------------------------
CMake has bootstrapped.  Now run gmake.
[[email protected] cmake-3.0.0]# gmake   #配置完成后进行编译
......

[ 99%] Building CXX object Tests/CMakeLib/CMakeFiles/runcompilecommands.dir/run_compile_commands.cxx.o
Linking CXX executable runcompilecommands
[ 99%] Built target runcompilecommands
Scanning dependencies of target foo
[ 99%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
Linking CXX static library libfoo.a
[ 99%] Built target foo
Scanning dependencies of target memcheck_fail
[ 99%] Building CXX object Tests/CTestTestMemcheck/CMakeFiles/memcheck_fail.dir/ret1.cxx.o
Linking CXX executable memcheck_fail
[ 99%] Built target memcheck_fail
Scanning dependencies of target pseudo_BC
[ 99%] Building CXX object Tests/CTestTestMemcheck/CMakeFiles/pseudo_BC.dir/ret0.cxx.o
Linking CXX executable BC
[ 99%] Built target pseudo_BC
Scanning dependencies of target pseudo_purify
[ 99%] Building CXX object Tests/CTestTestMemcheck/CMakeFiles/pseudo_purify.dir/ret0.cxx.o
Linking CXX executable purify
[ 99%] Built target pseudo_purify
Scanning dependencies of target pseudo_valgrind
[100%] Building CXX object Tests/CTestTestMemcheck/CMakeFiles/pseudo_valgrind.dir/ret0.cxx.o
Linking CXX executable valgrind
[100%] Built target pseudo_valgrind
Scanning dependencies of target pseudonl_BC
[100%] Building C object Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_BC.dir/ret0.c.o
Linking C executable BC
[100%] Built target pseudonl_BC
Scanning dependencies of target pseudonl_purify
[100%] Building C object Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_purify.dir/ret0.c.o
Linking C executable purify
[100%] Built target pseudonl_purify
Scanning dependencies of target pseudonl_valgrind
[100%] Building C object Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_valgrind.dir/ret0.c.o
Linking C executable valgrind
[100%] Built target pseudonl_valgrind
[[email protected] cmake-3.0.0]# make install  #编译完成后进行安装
......
-- Installing: /usr/local/share/cmake-3.0/Templates/CPack.GenericLicense.txt
-- Installing: /usr/local/share/cmake-3.0/Templates/DLLHeader.dsptemplate
-- Installing: /usr/local/share/cmake-3.0/Templates/EXEWinHeader.dsptemplate
-- Installing: /usr/local/share/cmake-3.0/Templates/CPack.GenericWelcome.txt
-- Installing: /usr/local/share/cmake-3.0/Templates/CTestScript.cmake.in
-- Installing: /usr/local/share/cmake-3.0/Templates/TestDriver.cxx.in
-- Installing: /usr/local/share/cmake-3.0/Templates/CMakeVSMacros1.vsmacros
-- Installing: /usr/local/share/cmake-3.0/Templates/CMakeVSMacros2.vsmacros
-- Installing: /usr/local/share/cmake-3.0/Templates/EXEFooter.dsptemplate
-- Installing: /usr/local/share/cmake-3.0/Templates/cygwin-package.sh.in
-- Installing: /usr/local/share/cmake-3.0/Templates/CPackConfig.cmake.in
-- Installing: /usr/local/share/cmake-3.0/Templates/staticLibFooter.dsptemplate
-- Installing: /usr/local/share/cmake-3.0/Templates/CMakeVisualStudio6Configurations.cmake
-- Installing: /usr/local/share/cmake-3.0/Templates/CPack.GenericDescription.txt
-- Installing: /usr/local/share/cmake-3.0/Templates/EXEHeader.dsptemplate
-- Installing: /usr/local/share/cmake-3.0/Templates/staticLibHeader.dsptemplate
-- Installing: /usr/local/doc/cmake-3.0/cmsys/Copyright.txt
-- Installing: /usr/local/doc/cmake-3.0/cmzlib/Copyright.txt
-- Installing: /usr/local/doc/cmake-3.0/cmcurl/COPYING
-- Installing: /usr/local/doc/cmake-3.0/cmcompress/Copyright.txt
-- Installing: /usr/local/doc/cmake-3.0/cmlibarchive/COPYING
-- Installing: /usr/local/doc/cmake-3.0/cmexpat/COPYING
-- Installing: /usr/local/bin/ccmake
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/bin/cpack
-- Installing: /usr/local/share/cmake-3.0/include/cmCPluginAPI.h
-- Installing: /usr/local/share/cmake-3.0/editors/vim/cmake-help.vim
-- Installing: /usr/local/share/cmake-3.0/editors/vim/cmake-indent.vim
-- Installing: /usr/local/share/cmake-3.0/editors/vim/cmake-syntax.vim
-- Installing: /usr/local/share/cmake-3.0/editors/emacs/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/cmake-3.0/completions/cmake
-- Installing: /usr/local/share/cmake-3.0/completions/cpack
-- Installing: /usr/local/share/cmake-3.0/completions/ctest

2.创建mysql用户信息

[[email protected] ~]# useradd -M -u 49 -s /sbin/nologin mysql
[[email protected] ~]# mkdir -p /var/mysql/data
[[email protected] ~]# mkdir -p /var/mysql/log
[[email protected] ~]# chown -R mysql.mysql /var/mysql
[[email protected] ~]# ll /var/mysql
total 8
drwxr-xr-x 2 mysql mysql 4096 Feb  1 12:44 data
drwxr-xr-x 2 mysql mysql 4096 Feb  1 12:44 log

3.编译安装mysql

[[email protected] local]# mkdir mysql
[[email protected] local]# cd mysql/
[[email protected] mysql]# pwd
/usr/local/mysql
[[email protected] data]# mkdir /var/lib/mysql
[[email protected] data]# cd /var/lib/mysql/
[[email protected] mysql]# pwd
/var/lib/mysql
[[email protected] mysql]# cd /root/mysql-5.6.19
[[email protected] mysql-5.6.19]# cmake -DCMAKE_BUILD_TYPE:STRING=Release > -DMYSQL_USER=mysql > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql > -DMYSQL_DATADIR=/var/mysql/data > -DSYSCONFDIR=/etc > -DWITH_MYISAM_STORAGE_ENGINE=1 > -DWITH_INNOBASE_STORAGE_ENGINE=1 > -DWITH_MEMORY_STORAGE_ENGINE=1 > -DWITH_ARCHIVE_STORAGE_ENGINE=1 > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 > -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 > -DWITH_READLINE=1 > -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock > -DMYSQL_TCP_PORT=3306 > -DENABLED_LOCAL_INFILE=1 > -DEXTRA_CHARSETS=all > -DDEFAULT_CHARSET=utf8 > -DWITH_SSL=yes  > -DDEFAULT_COLLATION=utf8_general_ci
......
[[email protected] cmake-3.0.0]# make
.......
[ 99%] Generating mysqlserver_depends.c
Scanning dependencies of target mysqlserver
[ 99%] Building C object libmysqld/CMakeFiles/mysqlserver.dir/mysqlserver_depends.c.o
Linking C static library libmysqld.a
/usr/bin/ar: creating /root/mysql-5.6.19/libmysqld//libmysqld.a
[ 99%] Built target mysqlserver
Scanning dependencies of target mysql_client_test_embedded
[ 99%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/tests/mysql_client_test.c.o
Linking CXX executable mysql_client_test_embedded
[ 99%] Built target mysql_client_test_embedded
Scanning dependencies of target mysql_embedded
[ 99%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o
[ 99%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o
/root/mysql-5.6.19/client/mysql.cc:1555: warning: dereferencing type-punned pointer will break strict-aliasing rules
/root/mysql-5.6.19/client/mysql.cc:1555: warning: dereferencing type-punned pointer will break strict-aliasing rules
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
/root/mysql-5.6.19/client/mysqltest.cc: In function 鈥榗har* re_eprint(int)鈥?
/root/mysql-5.6.19/client/mysqltest.cc:8236: warning: unused variable 鈥榣en鈥?
                                                                                Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[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

编译的可能会报错,要注意内存的大小,去掉-DWITHOUT_PARTITION_STORAGE_ENGINE=1参数
-DWITHOUT_PARTITION_STORAGE_ENGINE=1参数在本次make的时候大约80%的时候会报错

注意:如果重新编译或者编译出错了,需要清除旧的对象文件和缓存信息。

# make clean

# rm -f CMakeCache.txt

# rm -rf /etc/my.cnf

然后再:make , make install即可。

[[email protected] cmake-3.0.0]# make install
......
-- Installing: /usr/local/mysql/man/man1/myisam_ftdump.1
-- Installing: /usr/local/mysql/man/man1/mysql_install_db.1
-- Installing: /usr/local/mysql/man/man1/mysql_config.1
-- Installing: /usr/local/mysql/man/man1/mysql_tzinfo_to_sql.1
-- Installing: /usr/local/mysql/man/man1/mysqlbug.1
-- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1
-- Installing: /usr/local/mysql/man/man1/mysqlshow.1
-- Installing: /usr/local/mysql/man/man1/myisamchk.1
-- Installing: /usr/local/mysql/man/man1/mysql_find_rows.1
-- Installing: /usr/local/mysql/man/man1/mysqlcheck.1
-- Installing: /usr/local/mysql/man/man1/mysqlimport.1
-- Installing: /usr/local/mysql/man/man1/innochecksum.1
-- Installing: /usr/local/mysql/man/man1/mysqld_safe.1
-- Installing: /usr/local/mysql/man/man1/msql2mysql.1
-- Installing: /usr/local/mysql/man/man1/mysql_client_test.1
-- Installing: /usr/local/mysql/man/man1/mysql_plugin.1
-- Installing: /usr/local/mysql/man/man1/mysql_client_test_embedded.1
-- Installing: /usr/local/mysql/man/man1/mysql_secure_installation.1
-- Installing: /usr/local/mysql/man/man1/mysql.server.1
-- Installing: /usr/local/mysql/man/man1/mysql_fix_extensions.1
-- Installing: /usr/local/mysql/man/man1/resolve_stack_dump.1
-- Installing: /usr/local/mysql/man/man1/mysql-stress-test.pl.1
-- Installing: /usr/local/mysql/man/man1/mysql.1
-- Installing: /usr/local/mysql/man/man1/mysqladmin.1
-- Installing: /usr/local/mysql/man/man1/mysql-test-run.pl.1
-- Installing: /usr/local/mysql/man/man1/mysql_convert_table_format.1
-- Installing: /usr/local/mysql/man/man1/my_print_defaults.1
-- Installing: /usr/local/mysql/man/man1/mysqldump.1
-- Installing: /usr/local/mysql/man/man1/mysql_setpermission.1
-- Installing: /usr/local/mysql/man/man1/mysqlhotcopy.1
-- Installing: /usr/local/mysql/man/man1/perror.1
-- Installing: /usr/local/mysql/man/man8/mysqld.8
[[email protected] mysql]# ll /usr/local/mysql/
total 160
drwxr-xr-x  2 root root  4096 Feb  1 15:43 bin
-rw-r--r--  1 root root 17987 May  6  2014 COPYING
drwxr-xr-x  3 root root  4096 Feb  1 15:42 data
drwxr-xr-x  2 root root  4096 Feb  1 15:42 docs
drwxr-xr-x  3 root root  4096 Feb  1 15:42 include
-rw-r--r--  1 root root 89163 May  6  2014 INSTALL-BINARY
drwxr-xr-x  3 root root  4096 Feb  1 15:42 lib
drwxr-xr-x  4 root root  4096 Feb  1 15:43 man
drwxr-xr-x 10 root root  4096 Feb  1 15:43 mysql-test
-rw-r--r--  1 root root  2496 May  6  2014 README
drwxr-xr-x  2 root root  4096 Feb  1 15:43 scripts
drwxr-xr-x 28 root root  4096 Feb  1 15:43 share
drwxr-xr-x  4 root root  4096 Feb  1 15:43 sql-bench
drwxr-xr-x  2 root root  4096 Feb  1 15:43 support-files

4.修改配置

[[email protected] mysql-5.6.19]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql-5.6.19]# vi /etc/my.cnf 

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
datadir =/var/mysql/data
skip-name-resolve
lower_case_table_names = 1
character-set-server = utf8
query_cache_limit = 10M
max_heap_table_size = 64M
max_connections = 2000
log-error=/var/mysql/log/mysql_error.log
pid-file =/var/mysql/log/mysql.pid
general_log = 1
log_output= TABLE
log-bin =/var/mysql/log/mysql_bin
slow_query_log = ON
slow_query_log_file=/var/mysql/log/mysql_slow.log
long_query_time = 2
explicit_defaults_for_timestamp=true
"/etc/my.cnf" 46L, 1531C written
[[email protected] mysql-5.6.19]# 

4.初始化数据库

[[email protected] mysql-5.6.19]# /usr/local/mysql/scripts/mysql_install_db > --user=mysql > --datadir=/var/mysql/data > --basedir=/usr/local/mysql > --log-output=file
Installing MySQL system tables...[[email protected] mysql-5.6.19]# 

系统只提示Installing MySQL system tables...就结束了,感觉不正常,查看系统日志:

[[email protected] log]# tail -f mysql_error.log

2016-02-01 16:39:16 14116 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2016-02-01 16:39:16 14116 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-01 16:39:16 14116 [Note] InnoDB: Mutexes and rw_locks use InnoDB‘s own implementation
2016-02-01 16:39:16 14116 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-01 16:39:16 14116 [Note] InnoDB: Using Linux native AIO
2016-02-01 16:39:16 14116 [Note] InnoDB: Not using CPU crc32 instructions
2016-02-01 16:39:16 14116 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-01 16:39:16 14116 [Note] InnoDB: Completed initialization of buffer pool
2016-02-01 16:39:16 14116 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-02-01 16:39:16 14116 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-02-01 16:39:16 14116 [Note] InnoDB: Database physically writes the file full: wait...    --此处发现空间已满
2016-02-01 16:39:16 b7f2b6d0 InnoDB: Error: Write to file ./ibdata1 failed at offset 0.
InnoDB: 1048576 bytes should have been written, only -1 were written.
InnoDB: Operating system error number 28.
InnoDB: Check that your OS and file system support files of this size.
InnoDB: Check also that the disk is not full or a disk quota exceeded.
InnoDB: Error number 28 means ‘No space left on device‘.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
2016-02-01 16:39:16 14116 [ERROR] InnoDB: Error in creating ./ibdata1: probably out of disk space
2016-02-01 16:39:16 14116 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2016-02-01 16:39:16 14116 [ERROR] Plugin ‘InnoDB‘ init function returned error.
2016-02-01 16:39:16 14116 [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed.
2016-02-01 16:39:16 14116 [ERROR] /usr/loc
[[email protected] ~]$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             36554508  35078436         0 100% /
tmpfs                  1037712         0   1037712   0% /dev/shm

发现磁盘空间不足,增加磁盘后将mysql的数据及日志文件挂载到新磁盘,以下为挂载过程(虚拟机):

[[email protected] ~]# cd /var/mysql/
[[email protected] mysql]# ls
data  log
[[email protected] mysql]# ll
total 8
drwxr-xr-x 4 mysql mysql 4096 Feb  1 16:39 data
drwxr-xr-x 2 mysql mysql 4096 Feb  1 16:39 log
[[email protected] mysql]# ll -d /var/mysql
drwxr-xr-x 4 mysql mysql 4096 Feb  1 12:44 /var/mysql
[[email protected] mysql]# rm -rf *
[[email protected] mysql]# vi /etc/fstab 

LABEL=/                 /                       ext3    defaults        1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
/dev/sdb1              /var/mysql               ext3    defaults        0 0
~
"/etc/fstab" 7L, 532C written
[[email protected] mysql]# mount -a
[[email protected] mysql]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda1                35698     34257         0 100% /
tmpfs                     1014         0      1014   0% /dev/shm
/dev/sdb1                10077       151      9414   2% /var/mysql
[[email protected] mysql]# mkdir data
[[email protected] mysql]# mkdir log
[[email protected] mysql]# ll
total 8
drwxr-xr-x 2 root root 4096 Feb  2 08:36 data
drwxr-xr-x 2 root root 4096 Feb  2 08:36 log
[[email protected] mysql]# chown mysql.mysql *
[[email protected] mysql]# ll
total 8
drwxr-xr-x 2 mysql mysql 4096 Feb  2 08:38 data
drwxr-xr-x 2 mysql mysql 4096 Feb  2 08:37 log
[[email protected] mysql]# 

然后再清理下/dev/sda1下不用文件,清理下oracle下的归档文件及日志文件:

[[email protected] archivelog_dest]$ df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda1                35698     17766     16091  53% /
tmpfs                     1014         0      1014   0% /dev/shm
/dev/sdb1                10077       151      9414   2% /var/mysql

重新执行mysql_install_db脚本:

[[email protected] mysql-5.6.19]# /usr/local/mysql/scripts/mysql_install_db > --user=mysql > --datadir=/var/mysql/data > --basedir=/usr/local/mysql > --log-output=file
Installing MySQL system tables...OK

Filling help tables...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/mysql/bin/mysqladmin -u root password ‘new-password‘
  /usr/local/mysql/bin/mysqladmin -u root -h edu password ‘new-password‘

Alternatively you can run:

  /usr/local/mysql/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/mysql/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 at http://bugs.mysql.com/

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

WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

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

5.启动mysql数据库

[[email protected] mysql-5.6.19]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[[email protected] mysql-5.6.19]# ln -s /usr/local/mysql/lib/* /usr/lib/
[[email protected] mysql-5.6.19]# ln -s /usr/local/mysql/include/* /usr/include/
[[email protected] mysql-5.6.19]# ldconfig
[[email protected] mysql-5.6.19]# cp /root/mysql-5.6.19/support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql-5.6.19]# chmod 755 /etc/init.d/mysqld
[[email protected] mysql-5.6.19]# /etc/init.d/mysqld status
MySQL is not running                                       [FAILED]
[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL....The server quit without updating PID file[FAILED]ysql/log/mysql.pid).

发现启动失败,查看错误日志:

[[email protected] log]# tail -f mysql_error.log
2016-02-02 09:21:00 5875 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2016-02-02 09:21:00 5875 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-02 09:21:00 5875 [Note] InnoDB: Mutexes and rw_locks use InnoDB‘s own implementation
2016-02-02 09:21:00 5875 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-02 09:21:00 5875 [Note] InnoDB: Using Linux native AIO
2016-02-02 09:21:00 5875 [Note] InnoDB: Not using CPU crc32 instructions
2016-02-02 09:21:00 5875 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-02 09:21:00 5875 [Note] InnoDB: Completed initialization of buffer pool
2016-02-02 09:21:00 5875 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-02 09:21:00 5875 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-02 09:21:00 5875 [Note] InnoDB: Waiting for purge to start
2016-02-02 09:21:00 5875 [Note] InnoDB: 5.6.19 started; log sequence number 1626037
2016-02-02 09:21:00 5875 [Note] Server hostname (bind-address): ‘*‘; port: 3306
2016-02-02 09:21:00 5875 [Note] IPv6 is available.
2016-02-02 09:21:00 5875 [Note]   - ‘::‘ resolves to ‘::‘;
2016-02-02 09:21:00 5875 [Note] Server socket created on IP: ‘::‘.
2016-02-02 09:21:00 5875 [ERROR] Can‘t start server : Bind on unix socket: Permission denied   --发现权限应该不对
2016-02-02 09:21:00 5875 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?  

修改权限重新启动:

[[email protected] lib]# pwd
/var/lib
[[email protected] lib]# ll -d mysql/
drwxr-xr-x 2 root root 4096 Feb  1 12:52 mysql/
[[email protected] lib]# chown -R mysql.mysql mysql
[[email protected] lib]# ll -d mysql/
drwxr-xr-x 2 mysql mysql 4096 Feb  1 12:52 mysql/
[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL...                                          [  OK  ]

6.mysql访问测试

[[email protected] ~]# mysqladmin -u root password ‘123456‘
[[email protected] ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.19-log Source distribution

Copyright (c) 2000, 2014, 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> select version()
    -> ;
+------------+
| version()  |
+------------+
| 5.6.19-log |
+------------+
1 row in set (0.00 sec)

mysql> show master logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql_bin.000001 |     69300 |
| mysql_bin.000002 |   1237667 |
| mysql_bin.000003 |       143 |
| mysql_bin.000004 |       143 |
| mysql_bin.000005 |       262 |
+------------------+-----------+
5 rows in set (0.00 sec)

mysql> exit
Bye
[[email protected] ~]# mysql -V
mysql  Ver 14.14 Distrib 5.6.19, for Linux (i686) using  EditLine wrapper
[[email protected] ~]# mysql --version
mysql  Ver 14.14 Distrib 5.6.19, for Linux (i686) using  EditLine wrapper

参考:

cmake参数

http://blog.sina.com.cn/s/blog_68c25adf0101402v.html

http://blog.csdn.net/lyd518/article/details/20284379

make命令

http://www.jb51.net/LINUXjishu/65444.html

mysql配置文件my.cnf详解[部分]

http://www.cnblogs.com/toby/articles/2198697.html

------------------------------------cmake---------------------------
-DCMAKE_INSTALL_PREFIX= 指向mysql安装目录
-DINSTALL_SBINDIR=sbin 指向可执行文件目录(prefix/sbin)
-DMYSQL_DATADIR=/var/lib/mysql 指向mysql数据文件目录(/var/lib/mysql)
-DSYSCONFDIR=/etc/mysql 指向mysql配置文件目录(/etc/mysql)
-DINSTALL_PLUGINDIR=lib/mysql/plugin 指向插件目录(prefix/lib/mysql/plugin)
-DINSTALL_MANDIR=share/man 指向man文档目录(prefix/share/man)
-DINSTALL_SHAREDIR=share 指向aclocal/mysql.m4安装目录(prefix/share)
-DINSTALL_LIBDIR=lib/mysql 指向对象代码库目录(prefix/lib/mysql)
-DINSTALL_INCLUDEDIR=include/mysql 指向头文件目录(prefix/include/mysql)
-DINSTALL_INFODIR=share/info 指向info文档存放目录(prefix/share/info)
prefix官方推荐设为/usr
Storage Engine相关
类型csv,myisam,myisammrg,heap,innobase,archive,blackhole
若想启用某个引擎的支持:-DWITH_<ENGINE>_STORAGE_ENGINE=1
如:
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
若想禁用某个引擎的支持:-DWITHOUT_<ENGINE>_STORAGE_ENGINE=1
如:
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
Library相关
-DWITH_READLINE=1 启用readline库支持(提供可编辑的命令行)
-DWITH_SSL=system 启用ssl库支持(安全套接层)
-DWITH_ZLIB=system 启用libz库支持(zib、gzib相关)
-DWTIH_LIBWRAP=0 禁用libwrap库(实现了通用TCP包装的功能,为网络服务守护进程使用)
-DMYSQL_TCP_PORT=3306 指定TCP端口为3306
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock 指定mysql.sock路径
-DENABLED_LOCAL_INFILE=1 启用本地数据导入支持
-DEXTRA_CHARSETS=all 启用额外的字符集类型(默认为all)
-DDEFAULT_CHARSET=utf8 指定默认的字符集为utf8
-DDEFAULT_COLLATION=utf8_general_ci 设定默认排序规则(utf8_general_ci快速/utf8_unicode_ci准确)
-DWITH_EMBEDDED_SERVER=1 编译嵌入式服务器支持
-DMYSQL_USER=mysql 指定mysql用户(默认为mysql)
-DWITH_DEBUG=0 禁用debug(默认为禁用)
-DENABLE_PROFILING=0 禁用Profiling分析(默认为开启)
-DWITH_COMMENT=‘string‘ 一个关于编译环境的描述性注释

--------------------------------make-----------------------------

make
根据Makefile文件编译源代码、连接、生成目标文件、可执行文件。
make clean
清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。
make install
将编译成功的可执行文件安装到系统目录中,一般为/usr/local/bin目录。
make dist
产生发布软件包文件(即distribution package)。这个命令将会将可执行文件及相关文件打包成一个tar.gz压缩的文件用来作为发布软件的软件包。
它会在当前目录下生成一个名字类似“PACKAGE-VERSION.tar.gz”的文件。PACKAGE和VERSION,是我们在configure.in中定义的AM_INIT_AUTOMAKE(PACKAGE, VERSION)。
make distcheck
生成发布软件包并对其进行测试检查,以确定发布包的正确性。这个操作将自动把压缩包文件解开,然后执行configure命令,并且执行make,来确认编译不出现错误,最后提示你软件包已经准备好,可以发布了。
make distclean
类似make clean,但同时也将configure生成的文件全部删除掉,包括Makefile文件。

时间: 2024-10-12 21:29:21

Red Hat5下源码安装mysql5.6过程记录的相关文章

Linux下源码安装Mysql5.5

本文主要介绍了如何在源码安装mysql5.5,所用系统为CentOS6.5 一.安装相应的开发环境 yum install -y ncurses-devel yum install -y libaio yum install -y bison yum install -y gcc-c++ yum install -y openssl-devel 二.安装cmake 跨平台编译器 # tar xf cmake-2.8.8.tar.gz # cd cmake-2.8.8 # ./bootstrap

在rhel7.2下源码安装mysql-5.6.35

如何在一台新机rhel7.2下源码安装mysql-5.6.35 一.前期准备工作 1.首先安装依赖包,避免在安装过程中出现问题 yum -y install gcc gcc-c++ cmake ncurses-devel autoconf perl perl-devel 2.下载源码包 源码包地址:https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz 3.创建mysql安装目录以及数据存放目录 [[email prot

Ubuntu15.04下源码安装MySQL5.6.26数据库

解决Ubuntu 15.04版下源码编译安装MySQL5.6.26数据库问题,这里提供依赖包下载,源码安装方法. (1)安装编译源码需要的包 sudoapt-get install make cmake gcc g++ bison libncurses5-dev 依赖包在博客附件里有下载.下面也有说明一些解决方法. 另外的:cmake-2.8.3.tar.gz安装啊.bison_3.0.2.dfsg-2_i386.deb.ncurses-5.9.tar.gz的依赖缺少的话自己可以去下载安装,由于

CentOS7下源码安装mysql5.6

目录 准备工作 运行环境 确认你的安装版本 下载mysql 安装mysql 准备安装环境 编译和安装 配置mysql 单实例配置      单实例配置方法          添加防火墙          启动mysql          重启mysql 多实例配置          什么是多实例          多实例配置方法          创建启动文件          初始化数据库          配置防火墙          启动mysql          登陆mysql    

Centos下源码安装MySQL5.5(单实例)

1.介质准备 注:由于Mysql5.5源码编译采用的CMAKE方式,所以事先下载cmake的安装包和MySQL5.5的安装包 下载地址如下: http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/ http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz 下载完成之后上传到指定的服务器上. 2.安装依赖包 需要安装的依赖包很多,所以建议采用yum源安装的方式安装,其实有很多包是选装的.(加粗字

centos 6.5_64bit最小化安装环境下源码安装mysql-5.6

一.操作环境 华为云服务 Centos 6.5_64bit最小化安装内网IP:10.124.156.237 mysql-5.6.20.tar.gz 二.源码编译安装流程 1.基础环境搭建 由于操作系统是最小化安装,因此一些常用的编译环境是没有安装的:加上我们的操作环境是内网,所以不能使用yum源.解决这个问题,可以从华为云购买一个临时公网Ip与我们服务器的内网IP进行邦定,这样我们就可以使用yum源来安装必要的编译环境了. yum -y install gccgcc-c++ vim tree m

Linux下源码安装mysql5.6

1.下载mysql到/usr/local/src/ cd /usr/local/src/ wget http://distfiles.macports.org/cmake/cmake-2.8.12.tar.gz wget http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz 2.编译安装cmake编译安装 mysql(最新版本都需要 cmake 编译安装) [[email protected] src]# tar 

Linux下源码安装MySQL5.6.30

环境简介 linux :cenos 6.5 mysql版本:mySQL5.6.30 Mysql5.6.30安装与mySQL5.1安装还是有一些区别了,需要使用cmake进行安装信息的配置.据说Mysql从5.5以后安装都需要cmake. Mysql5.6.30里面没有configure,没法通过./configure 进行安装配置,需要自己去生成配置信息 MySQL5.6.30安装 前期准备 创建mysql用户与mysql组 创建组:groupadd mysql 创建用户:useradd -r

CentOS 7下源码安装MySQL 5.7

网上说linux安装mysql服务分两种安装方法: ①源码安装,优点是安装包比较小,只有几十M左右,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: ②使用官方编译好的二进制文件安装,优点是安装速度快,安装步骤简单,缺点是安装包很大,300M左右(5.7版本的是600M左右), 对于第二种方法,我搞了一天,无果,到某个环节实在是无法走通,老大那边也不让搞了,隔了几天老大又吩咐我在生产服务器上安装mysql,这次我就按照第一种方法源码安装方式 下载源码安装包 http://dev.my