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!
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
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]#
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>