MySQL安装方式有多种,可以使用rpm包二进制安装,也可以使用源码进行编译安装。很显然,编译安装的好处很多,就是能够对将要使用的MysqL数据库进行定制,
对于特定的操作系统、特定的应用、特定的MysqL功能要求很适合。因此,这里记录一次MysqL 5.6 for REHL 6.4编译安装过程。
[root@arbiter ~]# uname -a
Linux arbiter 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@arbiter ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
[root@arbiter ~]#
[root@arbiter ~]# cat /etc/hosts
# Do not remove the following line, or varIoUs programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.144.111 arbiter
[root@arbiter ~]#
[root@arbiter cmake-2.8.10.2]# rpm -qa|grep MysqL
MysqL-libs-5.1.66-2.el6_3.x86_64
[root@arbiter cmake-2.8.10.2]# rpm -e --nodeps MysqL-libs
[root@arbiter cmake-2.8.10.2]# rpm -qa|grep MysqL
[root@arbiter cmake-2.8.10.2]#
2、检查MysqL编译安装必须的操作系统依赖包
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' make \
gcc-c++ \
libstdc++-devel \
ncurses-devel
[root@arbiter ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' make \
> gcc-c++ \
> libstdc++-devel \
> ncurses-devel
make-3.81-20.el6 (x86_64)
package gcc-c++ is not installed
package libstdc++-devel is not installed
package ncurses-devel is not installed
[root@arbiter ~]#
3、安装MysqL编译安装必须的操作系统依赖包
--挂载系统镜像配置本地的yum源
[root@arbiter ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@arbiter yum.repos.d]# cat local.repo
[local]
name = local
baseurl=file:///mnt/
enabled = 1
gpgcheck = 0
gpgkey =file://mnt/RPM-GPG-KEY-CentOS-6
[root@arbiter yum.repos.d]#
[root@arbiter yum.repos.d]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: InstallMedia base extras local updates
Cleaning up Everything
[root@arbiter yum.repos.d]#
--使用yum安装操作系统缺少的rpm包
yum -y install gcc-c++
ncurses-devel ncurses-devel
4、上传、解压并安装cmake
[root@arbiter ~]# ls
anaconda-ks.cfg cmake-2.8.10.2.tar Documents install.log Music pkg rpms test
Desktop Downloads install.log.syslog Pictures Public Templates Videos
[root@arbiter ~]# tar -xvf cmake-2.8.10.2.tar
--安装cmake
-- Performing Test run_pic_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cmake-2.8.10.2
---------------------------------------------
CMake has bootstrapped. Now run gmake.
[root@arbiter cmake-2.8.10.2]#
/root/cmake-2.8.10.2
[root@arbiter cmake-2.8.10.2]# gmake
......
[ 99%] Built target foo
Scanning dependencies of target memcheck_fail
[100%] Building C object Tests/CTestTestMemcheck/CMakeFiles/memcheck_fail.dir/ret1.c.o
Linking C executable memcheck_fail
[100%] Built target memcheck_fail
Scanning dependencies of target pseudo_BC
[100%] Building C object Tests/CTestTestMemcheck/CMakeFiles/pseudo_BC.dir/ret0.c.o
Linking C executable BC
[100%] Built target pseudo_BC
Scanning dependencies of target pseudo_purify
[100%] Building C object Tests/CTestTestMemcheck/CMakeFiles/pseudo_purify.dir/ret0.c.o
Linking C executable purify
[100%] Built target pseudo_purify
Scanning dependencies of target pseudo_valgrind
[100%] Building C object Tests/CTestTestMemcheck/CMakeFiles/pseudo_valgrind.dir/ret0.c.o
Linking C executable valgrind
[100%] Built target pseudo_valgrind
[root@arbiter cmake-2.8.10.2]#
[root@arbiter cmake-2.8.10.2]# pwd
/root/cmake-2.8.10.2
[root@arbiter cmake-2.8.10.2]# gmake install
......
-- Installing: /usr/local/doc/cmake-2.8/cpack.docbook
-- Installing: /usr/local/doc/cmake-2.8/ccmake.docbook
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/cmake-2.8/editors/vim/cmake-help.vim
-- Installing: /usr/local/share/cmake-2.8/editors/vim/cmake-indent.vim
-- Installing: /usr/local/share/cmake-2.8/editors/vim/cmake-Syntax.vim
-- Installing: /usr/local/share/cmake-2.8/editors/emacs/cmake-mode.el
-- Installing: /usr/local/share/cmake-2.8/completions/cmake
-- Installing: /usr/local/share/cmake-2.8/completions/cpack
-- Installing: /usr/local/share/cmake-2.8/completions/ctest
[root@arbiter cmake-2.8.10.2]#
anaconda-ks.cfg cmake-2.8.10.2.tar Documents install.log Music Pictures Public Templates Videos
cmake-2.8.10.2 Desktop Downloads install.log.syslog mysql-5.6.36.tar.gz pkg rpms test
[root@arbiter ~]#
[root@arbiter ~]# ls
anaconda-ks.cfg cmake-2.8.10.2.tar Documents install.log Music Pictures Public Templates Videos
cmake-2.8.10.2 Desktop Downloads install.log.syslog mysql-5.6.36.tar pkg rpms test
[root@arbiter ~]# tar -xvf mysql-5.6.36.tar
anaconda-ks.cfg cmake-2.8.10.2.tar Documents install.log Music mysql-5.6.36.tar pkg rpms test
cmake-2.8.10.2 Desktop Downloads install.log.syslog mysql-5.6.36 Pictures Public Templates Videos
[root@arbiter ~]#
> tail -l /etc/profile
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
unset i
unset -f pathmunge
[root@arbiter ~]# source /etc/profile
[root@arbiter ~]# echo $PATH
/application/MysqL/bin:/opt/mongo/mongosoft/bin:/home/mongo/Documents/maven/bin:/usr/java/jdk1.8.0_11/bin/:/opt/mongo/ycsb/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@arbiter ~]#
-rwxr-xr-x 1 root root 9188179 Jul 27 00:10 /usr/local/bin/cmake
[root@arbiter ~]#
> -DMysqL_DATADIR=/application/mysql-5.6/data \
> -DMysqL_UNIX_ADDR=/application/mysql-5.6/tmp/MysqL.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
> -DENABLED_LOCAL_INFILE=ON \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
> -DWITHOUT_PARTITION_STORAGE_ENGINE=0 \
> -DWITH_FAST_MUTEXES=1 \
> -DWITH_ZLIB=bundled \
> -DENABLED_LOCAL_INFILE=1 \
> -DWITH_READLINE=1 \
> -DWITH_EMbedDED_SERVER=1 \
> -DWITH_DEBUG=0 \
> -DMysqL_TCP_PORT=3306
-- Library MysqLserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFinitioNS: HAVE_CONfig_H
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DMY_PTHREAD_FASTMUTEX=1
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DMY_PTHREAD_FASTMUTEX=1
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
WITH_READLINE
-- Build files have been written to: /root/mysql-5.6.36
[root@arbiter mysql-5.6.36]#
-- Installing: /application/mysql-5.6/sql-bench/README
-- Installing: /application/mysql-5.6/sql-bench/test-big-tables
-- Installing: /application/mysql-5.6/sql-bench/innotest2
-- Installing: /application/mysql-5.6/sql-bench/run-all-tests
-- Installing: /application/mysql-5.6/sql-bench/test-connect
-- Installing: /application/mysql-5.6/sql-bench/test-alter-table
-- Installing: /application/mysql-5.6/sql-bench/test-wisconsin
[root@arbiter mysql-5.6.36]#
[root@arbiter mysql-5.6.36]#
[root@arbiter ~]# cat /etc/my.cnf
[MysqLd]
datadir=/application/mysql-5.6/data
socket=/application/mysql-5.6/tmp/MysqL.sock
user=MysqL
# disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[MysqLd_safe]
log-error=/application/mysql-5.6/log/MysqLd.log
pid-file=/application/mysql-5.6/run/MysqLd/MysqLd.pid
[root@arbiter ~]#
[root@arbiter MysqL]# cd scripts/
[root@arbiter scripts]# ls
MysqL_install_db
[root@arbiter scripts]# pwd
/application/MysqL/scripts
[root@arbiter scripts]# ls
MysqL_install_db
[root@arbiter scripts]# ./MysqL_install_db --basedir=/application/MysqL --datadir=/application/MysqL/data/ --user=MysqL
Installing MysqL system tables...2017-07-27 00:53:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-27 00:53:16 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-27 00:53:16 0 [Note] /application/MysqL/bin/MysqLd (MysqLd 5.6.36) starting as process 27357 ...
2017-07-27 00:53:16 27357 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-07-27 00:53:16 27357 [Note] InnoDB: The InnoDB memory heap is disabled
2017-07-27 00:53:16 27357 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-27 00:53:16 27357 [Note] InnoDB: Memory barrier is not used
2017-07-27 00:53:16 27357 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-27 00:53:16 27357 [Note] InnoDB: Using cpu crc32 instructions
2017-07-27 00:53:16 27357 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-07-27 00:53:16 27357 [Note] InnoDB: Completed initialization of buffer pool
2017-07-27 00:53:16 27357 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-07-27 00:53:16 27357 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-07-27 00:53:16 27357 [Note] InnoDB: Database physically writes the file full: wait...
2017-07-27 00:53:16 27357 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-07-27 00:53:16 27357 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-07-27 00:53:16 27357 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-07-27 00:53:16 27357 [Warning] InnoDB: New log files created, LSN=45781
2017-07-27 00:53:16 27357 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-07-27 00:53:16 27357 [Note] InnoDB: Doublewrite buffer created
2017-07-27 00:53:16 27357 [Note] InnoDB: 128 rollback segment(s) are active.
2017-07-27 00:53:16 27357 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-07-27 00:53:16 27357 [Note] InnoDB: Foreign key constraint system tables created
2017-07-27 00:53:16 27357 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-07-27 00:53:16 27357 [Note] InnoDB: Tablespace and datafile system tables created.
2017-07-27 00:53:16 27357 [Note] InnoDB: Waiting for purge to start
2017-07-27 00:53:16 27357 [Note] InnoDB: 5.6.36 started; log sequence number 0
2017-07-27 00:53:17 27357 [Note] binlog end
2017-07-27 00:53:17 27357 [Note] InnoDB: FTS optimize thread exiting.
2017-07-27 00:53:17 27357 [Note] InnoDB: Starting shutdown...
2017-07-27 00:53:18 27357 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2017-07-27 00:53:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-27 00:53:18 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-27 00:53:18 0 [Note] /application/MysqL/bin/MysqLd (MysqLd 5.6.36) starting as process 27379 ...
2017-07-27 00:53:18 27379 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-07-27 00:53:18 27379 [Note] InnoDB: The InnoDB memory heap is disabled
2017-07-27 00:53:18 27379 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-27 00:53:18 27379 [Note] InnoDB: Memory barrier is not used
2017-07-27 00:53:18 27379 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-27 00:53:18 27379 [Note] InnoDB: Using cpu crc32 instructions
2017-07-27 00:53:18 27379 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-07-27 00:53:18 27379 [Note] InnoDB: Completed initialization of buffer pool
2017-07-27 00:53:18 27379 [Note] InnoDB: Highest supported file format is Barracuda.
2017-07-27 00:53:18 27379 [Note] InnoDB: 128 rollback segment(s) are active.
2017-07-27 00:53:18 27379 [Note] InnoDB: Waiting for purge to start
2017-07-27 00:53:18 27379 [Note] InnoDB: 5.6.36 started; log sequence number 1625977
2017-07-27 00:53:18 27379 [Note] binlog end
2017-07-27 00:53:18 27379 [Note] InnoDB: FTS optimize thread exiting.
2017-07-27 00:53:18 27379 [Note] InnoDB: Starting shutdown...
2017-07-27 00:53:19 27379 [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:
/application/MysqL/bin/MysqLadmin -u root password 'new-password'
/application/MysqL/bin/MysqLadmin -u root -h arbiter password 'new-password'
Alternatively you can run:
/application/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 . ; /application/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
New default config file was created as /application/MysqL/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@arbiter scripts]#
[root@arbiter support-files]# ls
binary-configure magic my-default.cnf MysqLd_multi.server MysqL-log-rotate MysqL.server
[root@arbiter support-files]# pwd
/application/MysqL/support-files
[root@arbiter support-files]# cp MysqL.server /etc/init.d/MysqLd
[root@arbiter support-files]# chmod +x /etc/init.d/MysqLd
[root@arbiter support-files]#
[root@arbiter log]# /etc/init.d/MysqLd start
Starting MysqL. SUCCESS!
[root@arbiter log]#
[root@arbiter log]# MysqL
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.36 Source distribution
copyright (c) 2000, 2017, 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>
MysqL> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)
MysqL>
接下来就可以对MysqL进行业务数据库的安全、数据等的初始化了!!!
启动异常一、socket文件相关:
[root@arbiter log]# cat MysqLd.log
2017-07-27 01:06:19 28474 [Note] Plugin 'FEDERATED' is disabled.
2017-07-27 01:06:19 28474 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-07-27 01:06:19 28474 [Note] InnoDB: The InnoDB memory heap is disabled
2017-07-27 01:06:19 28474 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-27 01:06:19 28474 [Note] InnoDB: Memory barrier is not used
2017-07-27 01:06:19 28474 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-27 01:06:19 28474 [Note] InnoDB: Using cpu crc32 instructions
2017-07-27 01:06:19 28474 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-07-27 01:06:19 28474 [Note] InnoDB: Completed initialization of buffer pool
2017-07-27 01:06:19 28474 [Note] InnoDB: Highest supported file format is Barracuda.
2017-07-27 01:06:19 28474 [Note] InnoDB: 128 rollback segment(s) are active.
2017-07-27 01:06:19 28474 [Note] InnoDB: Waiting for purge to start
2017-07-27 01:06:19 28474 [Note] InnoDB: 5.6.36 started; log sequence number 1626027
2017-07-27 01:06:19 28474 [Note] Server hostname (bind-address): '*'; port: 3306
2017-07-27 01:06:19 28474 [Note] IPv6 is available.
2017-07-27 01:06:19 28474 [Note] - '::' resolves to '::';
2017-07-27 01:06:19 28474 [Note] Server socket created on IP: '::'.
2017-07-27 01:06:19 28474 [ERROR] Can't start server : Bind on unix socket: Permission denied
2017-07-27 01:06:19 28474 [ERROR] Do you already have another MysqLd server running on socket: /application/mysql-5.6/tmp/MysqL.sock ?
2017-07-27 01:06:19 28474 [ERROR] Aborting
原因是:my.cnf配置中MysqL.sock文件存放目录或权限有问题
解决方法:检查socket配置的路径是否存在,socket指定的路径下MysqL用户是否有读写权限
[root@arbiter ]# /etc/init.d/MysqLd start
Starting MysqL.170727 00:56:52 MysqLd_safe error: log-error set to '/application/mysql-5.6/log/MysqLd.log', however file don't exists. Create writable for user 'MysqL'.
ERROR! The server quit without updating PID file (/application/mysql-5.6/data/arbiter.pid).
[root@arbiter ]#
原因是:my.cnf配置的log目录不存在或MysqL用户对其没有读写权限
解决方法:检查相关路径是否存在并创建授权
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。