mysql安装三 linux源码安装mysql5.6.22
梳理了一下centos上安装mysql的三种方法:一是通过源码安装,二是用通用二进制包,三是通过不同linux release到系统包安装,centos上是RPM包安装。
linux源码安装mysql5.6.22
0
[root@host2 ~]# uname -a
Linux host2 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@host2 ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
1
根据官文指导,源码安装需要
CMake,可以从http://www.cmake.org下载(install steps:./configure;make;make install)
根据平台有异,建议最好有GNU make 3.75或更新版本,应该都有了,若无可以http://www.gnu.org/software/make/下载
ANSI C++编译器,GCC 4.2.1或更新版本,Sun Studio 12或更新版本, Visual Studio 2010或更新版本
如果要跑测试脚本需要perl,这个linux上应该已经有了,window上的话可使ActiveState Perl
可按如下步骤安装
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
2
下载
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz/from/http://cdn.mysql.com/
文件名为
mysql-5.6.22.tar.gz
3
查已装版本
[root@host2 backup]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
4
删之
[root@host2 backup]# yum remove mysql-libs-5.1.71-1.el6.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
。。。
Removed:
mysql-libs.x86_64 0:5.1.71-1.el6
Dependency Removed:
cronie.x86_64 0:1.4.4-12.el6
cronie-anacron.x86_64 0:1.4.4-12.el6
crontabs.noarch 0:1.10-33.el6
postfix.x86_64 2:2.6.6-2.2.el6_1
redhat-lsb.x86_64 0:4.0-7.el6.centos
redhat-lsb-compat.x86_64 0:4.0-7.el6.centos
redhat-lsb-core.x86_64 0:4.0-7.el6.centos
redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos
redhat-lsb-printing.x86_64 0:4.0-7.el6.centos
sysstat.x86_64 0:9.0.4-22.el6
Complete!
[root@host2 backup]#
# 平时装和删可如下
# shell> rpm -e MySQL-server-OLDVERSION.linux_glibc2.5.i386.rpm
# shell> rpm -ivh MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
# 或
# shell> yum remove MySQL-server-OLDVERSION.linux_glibc2.5.i386.rpm
# shell> yum install MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
查,看删干净了
[root@host2 backup]# find / -name mysql
[root@host2 backup]# find / -name *mysql*
/root/mysql-5.6.22.tar.gz
5
安装依赖
[root@host2 backup]# yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl
。。。
Complete!
[root@host2 backup]#
########################################
###这段留底,发时去掉######################
########################################
[root@host2 backup]#
[root@host2 backup]# rpm -qa | grep wget
wget-1.12-1.8.el6.x86_64
[root@host2 backup]# rpm -qa | grep gcc
libgcc-4.4.7-11.el6.x86_64
gcc-gnat-4.4.7-11.el6.x86_64
gcc-c++-4.4.7-11.el6.x86_64
gcc-gfortran-4.4.7-11.el6.x86_64
gcc-objc-4.4.7-11.el6.x86_64
gcc-java-4.4.7-11.el6.x86_64
gcc-4.4.7-11.el6.x86_64
gcc-objc++-4.4.7-11.el6.x86_64
[root@host2 backup]# rpm -qa | grep ncurser-devel
[root@host2 backup]# rpm -qa | grep cmake
[root@host2 backup]# rpm -qa | grep make
make-3.81-20.el6.x86_64
automake-1.11.1-4.el6.noarch
[root@host2 backup]# rpm -qa | grep gmake
[root@host2 backup]# rpm -qa | grep per
perl-Pod-Simple-3.13-136.el6_6.1.x86_64
perl-devel-5.10.1-136.el6_6.1.x86_64
perl-Text-Diff-1.37-2.1.el6.noarch
6
创建mysql用户和组
[root@host2 backup]# groupadd mysql
[root@host2 backup]# useradd -r -g mysql mysql
7
瞅一眼
[root@host2 backup]# id mysql
uid=495(mysql) gid=501(mysql) groups=501(mysql)
8
创建mysql安装目录和数据库文件存放目录
[root@host2 backup]# mkdir -p /usr/local/mysql
[root@host2 backup]# mkdir -p /usr/local/mysql/data
9
解出源码
[root@host2 mysqlsrc]# tar -zxvf mysql-5.6.22.tar.gz
[root@host2 mysqlsrc]# cd mysql-5.6.22
[root@host2 mysql-5.6.22]# ll
total 716
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 BUILD
-rw-r--r--. 1 7161 wheel 142 Nov 21 13:39 BUILD-CMAKE
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 client
drwxr-xr-x. 4 7161 wheel 4096 Nov 21 13:40 cmake
-rw-r--r--. 1 7161 wheel 21448 Nov 21 13:39 CMakeLists.txt
drwxr-xr-x. 3 7161 wheel 4096 Nov 21 13:40 cmd-line-utils
-rw-r--r--. 1 7161 wheel 19678 Nov 21 13:39 config.h.cmake
-rw-r--r--. 1 7161 wheel 36826 Nov 21 13:39 configure.cmake
-rw-r--r--. 1 7161 wheel 17987 Nov 21 13:39 COPYING
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 dbug
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 Docs
-rw-r--r--. 1 7161 wheel 65958 Nov 21 13:39 Doxyfile-perfschema
drwxr-xr-x. 3 7161 wheel 4096 Nov 21 13:40 extra
drwxr-xr-x. 4 7161 wheel 4096 Nov 21 13:40 include
-rw-r--r--. 1 7161 wheel 398695 Nov 21 13:40 INSTALL-SOURCE
-rw-r--r--. 1 7161 wheel 247 Nov 21 13:39 INSTALL-WIN-SOURCE
drwxr-xr-x. 7 7161 wheel 4096 Nov 21 13:40 libevent
drwxr-xr-x. 3 7161 wheel 4096 Nov 21 13:40 libmysql
drwxr-xr-x. 3 7161 wheel 4096 Nov 21 13:40 libmysqld
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 libservices
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 man
drwxr-xr-x. 10 7161 wheel 4096 Nov 21 13:40 mysql-test
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 mysys
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 mysys_ssl
drwxr-xr-x. 10 7161 wheel 4096 Nov 21 13:40 packaging
drwxr-xr-x. 9 7161 wheel 4096 Nov 21 13:40 plugin
-rw-r--r--. 1 7161 wheel 2496 Nov 21 13:39 README
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 regex
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 scripts
drwxr-xr-x. 4 7161 wheel 20480 Nov 21 13:40 sql
drwxr-xr-x. 5 7161 wheel 4096 Nov 21 13:40 sql-bench
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 sql-common
drwxr-xr-x. 13 7161 wheel 4096 Nov 21 13:40 storage
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 strings
drwxr-xr-x. 5 7161 wheel 4096 Nov 21 13:40 support-files
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 tests
drwxr-xr-x. 5 7161 wheel 4096 Nov 21 13:40 unittest
-rw-r--r--. 1 7161 wheel 88 Nov 21 13:39 VERSION
drwxr-xr-x. 3 7161 wheel 4096 Nov 21 13:40 vio
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 win
drwxr-xr-x. 2 7161 wheel 4096 Nov 21 13:40 zlib
[root@host2 mysql-5.6.22]#
10
这一步应该cmake配置,之前先看看cmake选项,有点长,不想看可略到11步
Listing Configuration Options
After the initial configuration step completes, you can examine the configuration options.
Short form:
cmake . -L
Short form plus description:
cmake . -LH
Long form (lists lots of options, including internal and advanced ones):
cmake . -LA
[root@host2 mysql-5.6.22]# cmake . -L
。。。
-- Configuring done
-- Generating done
-- Build files have been written to: /root/backup/mysqlsrc/mysql-5.6.22
-- Cache values
CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
CMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql
COMMUNITY_BUILD:BOOL=ON
ENABLED_PROFILING:BOOL=ON
ENABLE_DEBUG_SYNC:BOOL=ON
ENABLE_DOWNLOADS:BOOL=OFF
ENABLE_GCOV:BOOL=OFF
ENABLE_GPROF:BOOL=OFF
ENABLE_MEMCACHED_SASL:BOOL=OFF
ENABLE_MEMCACHED_SASL_PWDB:BOOL=OFF
FEATURE_SET:STRING=community
INSTALL_LAYOUT:STRING=STANDALONE
MYSQL_DATADIR:PATH=/usr/local/mysql/data
MYSQL_MAINTAINER_MODE:BOOL=OFF
OPTIMIZER_TRACE:BOOL=ON
TMPDIR:PATH=P_tmpdir
WITH_ARCHIVE_STORAGE_ENGINE:BOOL=ON
WITH_ASAN:BOOL=OFF
WITH_BLACKHOLE_STORAGE_ENGINE:BOOL=ON
WITH_DEBUG:BOOL=OFF
WITH_DEFAULT_COMPILER_OPTIONS:BOOL=ON
WITH_DEFAULT_FEATURE_SET:BOOL=ON
WITH_EDITLINE:STRING=bundled
WITH_EMBEDDED_SERVER:BOOL=ON
WITH_EMBEDDED_SHARED_LIBRARY:BOOL=OFF
WITH_EXAMPLE_STORAGE_ENGINE:BOOL=OFF
WITH_EXTRA_CHARSETS:STRING=all
WITH_FEDERATED_STORAGE_ENGINE:BOOL=ON
WITH_INNOBASE_STORAGE_ENGINE:BOOL=ON
WITH_INNODB_MEMCACHED:BOOL=OFF
WITH_LIBEVENT:STRING=bundled
WITH_LIBWRAP:BOOL=OFF
WITH_PARTITION_STORAGE_ENGINE:BOOL=ON
WITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON
WITH_PIC:BOOL=OFF
WITH_SSL:STRING=bundled
WITH_UNIT_TESTS:BOOL=ON
WITH_VALGRIND:BOOL=OFF
WITH_ZLIB:STRING=bundled
[root@host2 mysql-5.6.22]#
[root@host2 mysql-5.6.22]# cmake . -LH
-- Running cmake version 2.8.12.2
-- MySQL 5.6.22
-- Packaging as: mysql-5.6.22-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.8.12.2
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- 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
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /root/backup/mysqlsrc/mysql-5.6.22
-- Cache values
// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel
CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
// install prefix
CMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql
// Set to true if this is a community build
COMMUNITY_BUILD:BOOL=ON
// Enable profiling
ENABLED_PROFILING:BOOL=ON
// Enable debug sync (debug builds only)
ENABLE_DEBUG_SYNC:BOOL=ON
// Download and build 3rd party source code components, e.g. google mock
ENABLE_DOWNLOADS:BOOL=OFF
// Enable gcov (debug, Linux builds only)
ENABLE_GCOV:BOOL=OFF
// Enable gprof (optimized, Linux builds only)
ENABLE_GPROF:BOOL=OFF
// Enable SASL on InnoDB Memcached
ENABLE_MEMCACHED_SASL:BOOL=OFF
// Enable SASL on InnoDB Memcached
ENABLE_MEMCACHED_SASL_PWDB:BOOL=OFF
// Selection of features. Options are
- xsmall :
- small: embedded
- classic: embedded + archive + federated + blackhole
- large : embedded + archive + federated + blackhole + innodb
- xlarge: embedded + archive + federated + blackhole + innodb + partition
- community: all features (currently == xlarge)
FEATURE_SET:STRING=community
// Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer), RPM, DEB, SVR4
INSTALL_LAYOUT:STRING=STANDALONE
// default MySQL data directory
MYSQL_DATADIR:PATH=/usr/local/mysql/data
// MySQL maintainer-specific development environment
MYSQL_MAINTAINER_MODE:BOOL=OFF
// Support tracing of Optimizer
OPTIMIZER_TRACE:BOOL=ON
// PATH to MySQL TMP dir. Defaults to the P_tmpdir macro in
TMPDIR:PATH=P_tmpdir
// Link ARCHIVE statically to the server
WITH_ARCHIVE_STORAGE_ENGINE:BOOL=ON
// Enable address sanitizer
WITH_ASAN:BOOL=OFF
// Link BLACKHOLE statically to the server
WITH_BLACKHOLE_STORAGE_ENGINE:BOOL=ON
// Use dbug/safemutex
WITH_DEBUG:BOOL=OFF
// Use flags from cmake/build_configurations/compiler_options.cmake
WITH_DEFAULT_COMPILER_OPTIONS:BOOL=ON
// Use feature set in cmake/build_configurations/feature_set.cmake
WITH_DEFAULT_FEATURE_SET:BOOL=ON
// By default use bundled editline
WITH_EDITLINE:STRING=bundled
// Compile MySQL with embedded server
WITH_EMBEDDED_SERVER:BOOL=ON
// Generate shared version of embedded library (in addition to the static one)
WITH_EMBEDDED_SHARED_LIBRARY:BOOL=OFF
//
WITH_EXAMPLE_STORAGE_ENGINE:BOOL=OFF
// Options are: none, complex, all
WITH_EXTRA_CHARSETS:STRING=all
// Link FEDERATED statically to the server
WITH_FEDERATED_STORAGE_ENGINE:BOOL=ON
// Link INNOBASE statically to the server
WITH_INNOBASE_STORAGE_ENGINE:BOOL=ON
//
WITH_INNODB_MEMCACHED:BOOL=OFF
// By default use bundled libevent on this platform
WITH_LIBEVENT:STRING=bundled
// Compile with tcp wrappers support
WITH_LIBWRAP:BOOL=OFF
// Link PARTITION statically to the server
WITH_PARTITION_STORAGE_ENGINE:BOOL=ON
// Link PERFSCHEMA statically to the server
WITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON
// Generate PIC objects
WITH_PIC:BOOL=OFF
// bundled (use yassl), yes (prefer os library if present, otherwise use bundled), system (use os library),
WITH_SSL:STRING=bundled
// Compile MySQL with unit tests
WITH_UNIT_TESTS:BOOL=ON
// Valgrind instrumentation
WITH_VALGRIND:BOOL=OFF
//
WITH_ZLIB:STRING=bundled
[root@host2 mysql-5.6.22]#
[root@host2 mysql-5.6.22]# cmake . -LA
-- Running cmake version 2.8.12.2
-- MySQL 5.6.22
-- Packaging as: mysql-5.6.22-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.8.12.2
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- 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
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /root/backup/mysqlsrc/mysql-5.6.22
-- Cache values
ACLOCAL_EXECUTABLE:FILEPATH=/usr/bin/aclocal
AUTOCONF_EXECUTABLE:FILEPATH=/usr/bin/autoconf
AUTOHEADER_EXECUTABLE:FILEPATH=/usr/bin/autoheader
AUTOMAKE_EXECUTABLE:FILEPATH=/usr/bin/automake
AWK_EXECUTABLE:FILEPATH=/usr/bin/gawk
BACKUP_TEST:BOOL=OFF
BISON_EXECUTABLE:FILEPATH=/usr/bin/bison
BZR_EXECUTABLE:FILEPATH=BZR_EXECUTABLE-NOTFOUND
CAT_EXECUTABLE:FILEPATH=/bin/cat
CMAKE_AR:FILEPATH=/usr/bin/ar
CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
CMAKE_COLOR_MAKEFILE:BOOL=ON
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
CMAKE_CXX_FLAGS:STRING=
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
CMAKE_C_FLAGS:STRING=
CMAKE_C_FLAGS_DEBUG:STRING=-g
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_EXE_LINKER_FLAGS:STRING=
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
CMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql
CMAKE_LINKER:FILEPATH=/usr/bin/ld
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake
CMAKE_MODULE_LINKER_FLAGS:STRING=
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_NM:FILEPATH=/usr/bin/nm
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
CMAKE_SHARED_LINKER_FLAGS:STRING=
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
CMAKE_SKIP_RPATH:BOOL=NO
CMAKE_STATIC_LINKER_FLAGS:STRING=
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_STRIP:FILEPATH=/usr/bin/strip
CMAKE_USE_RELATIVE_PATHS:BOOL=OFF
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
COMMUNITY_BUILD:BOOL=ON
CURSES_CURSES_H_PATH:PATH=/usr/include
CURSES_CURSES_LIBRARY:FILEPATH=/usr/lib64/libcurses.so
CURSES_EXTRA_LIBRARY:FILEPATH=CURSES_EXTRA_LIBRARY-NOTFOUND
CURSES_FORM_LIBRARY:FILEPATH=/usr/lib64/libform.so
CURSES_HAVE_CURSES_H:FILEPATH=/usr/include/curses.h
CURSES_INCLUDE_PATH:FILEPATH=/usr/include
CURSES_LIBRARY:FILEPATH=/usr/lib64/libcurses.so
CURSES_NCURSES_LIBRARY:FILEPATH=/usr/lib64/libncurses.so
CYBOZU:BOOL=OFF
DEBUG_EXTNAME:BOOL=OFF
DISABLE_SHARED:BOOL=OFF
DTRACE:FILEPATH=DTRACE-NOTFOUND
ENABLED_LOCAL_INFILE:BOOL=OFF
ENABLED_PROFILING:BOOL=ON
ENABLE_DEBUG_SYNC:BOOL=ON
ENABLE_DOWNLOADS:BOOL=OFF
ENABLE_GCOV:BOOL=OFF
ENABLE_GPROF:BOOL=OFF
ENABLE_MEMCACHED_SASL:BOOL=OFF
ENABLE_MEMCACHED_SASL_PWDB:BOOL=OFF
FEATURE_SET:STRING=community
FORM_LIBRARY:FILEPATH=/usr/lib64/libform.so
GETCONF:FILEPATH=/usr/bin/getconf
GLIBTOOLIZE_EXECUTABLE:FILEPATH=GLIBTOOLIZE_EXECUTABLE-NOTFOUND
GTAR_EXECUTABLE:FILEPATH=/bin/gtar
INNODB_COMPILER_HINTS:BOOL=ON
INNODB_PAGE_ATOMIC_REF_COUNT:BOOL=ON
INSTALL_BINDIR:STRING=bin
INSTALL_DOCDIR:STRING=docs
INSTALL_DOCREADMEDIR:STRING=.
INSTALL_INCLUDEDIR:STRING=include
INSTALL_INFODIR:STRING=docs
INSTALL_LAYOUT:STRING=STANDALONE
INSTALL_LIBDIR:STRING=lib
INSTALL_MANDIR:STRING=man
INSTALL_MYSQLDATADIR:STRING=data
INSTALL_MYSQLSHAREDIR:STRING=share
INSTALL_MYSQLTESTDIR:STRING=mysql-test
INSTALL_PLUGINDIR:STRING=lib/plugin
INSTALL_PLUGINTESTDIR:STRING=
INSTALL_SBINDIR:STRING=bin
INSTALL_SCRIPTDIR:STRING=scripts
INSTALL_SHAREDIR:STRING=share
INSTALL_SQLBENCHDIR:STRING=.
INSTALL_SUPPORTFILESDIR:STRING=support-files
LIBTOOLIZE_EXECUTABLE:FILEPATH=LIBTOOLIZE_EXECUTABLE-NOTFOUND
MANUFACTURER:STRING=Built from Source
MYSQL_DATADIR:PATH=/usr/local/mysql/data
MYSQL_DOCS_LOCATION:PATH=
MYSQL_MAINTAINER_MODE:BOOL=OFF
MYSQL_PROJECT_NAME:STRING=MySQL
OPTIMIZER_TRACE:BOOL=ON
SYSCONFDIR:PATH=/usr/local/mysql/etc
TAR_EXECUTABLE:FILEPATH=/bin/tar
TMPDIR:PATH=P_tmpdir
WITHOUT_EXAMPLE_STORAGE_ENGINE:BOOL=ON
WITHOUT_SERVER:BOOL=OFF
WITH_ARCHIVE_STORAGE_ENGINE:BOOL=ON
WITH_ASAN:BOOL=OFF
WITH_ATOMIC_LOCKS:STRING=
WITH_BLACKHOLE_STORAGE_ENGINE:BOOL=ON
WITH_DEBUG:BOOL=OFF
WITH_DEFAULT_COMPILER_OPTIONS:BOOL=ON
WITH_DEFAULT_FEATURE_SET:BOOL=ON
WITH_EDITLINE:STRING=bundled
WITH_EMBEDDED_SERVER:BOOL=ON
WITH_EMBEDDED_SHARED_LIBRARY:BOOL=OFF
WITH_EXAMPLE_STORAGE_ENGINE:BOOL=OFF
WITH_EXTRA_CHARSETS:STRING=all
WITH_FAST_MUTEXES:BOOL=OFF
WITH_FEDERATED_STORAGE_ENGINE:BOOL=ON
WITH_INNOBASE_STORAGE_ENGINE:BOOL=ON
WITH_INNODB_MEMCACHED:BOOL=OFF
WITH_LIBEVENT:STRING=bundled
WITH_LIBWRAP:BOOL=OFF
WITH_MYSQLD_LDFLAGS:STRING=
WITH_PARTITION_STORAGE_ENGINE:BOOL=ON
WITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON
WITH_PIC:BOOL=OFF
WITH_SSL:STRING=bundled
WITH_UNIT_TESTS:BOOL=ON
WITH_VALGRIND:BOOL=OFF
WITH_ZLIB:STRING=bundled
[root@host2 mysql-5.6.22]#
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /etc/my.cnf
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
[root@ho st2 mysql-5.6.22]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DENABLED_LOCAL_INFILE=1 \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DMYSQL_USER=mysql \
> -DMYSQL_TCP_PORT=3306
-- Running cmake version 2.8.12.2
-- MySQL 5.6.22
-- Packaging as: mysql-5.6.22-Linux-x86_64
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.8.12.2
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- 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
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
MYSQL_USER
WITH_MEMORY_STORAGE_ENGINE
WITH_READLINE
-- Build files have been written to: /root/backup/mysqlsrc/mysql-5.6.22
[root@host2 mysql-5.6.22]#
参考
4.4.3 Listing Configuration Options
http://dev.mysql.com/doc/internals/en/listing-configuration-options.html
11
cmake配置
[root@host2 mysql-5.6.22]# make clean
[root@host2 mysql-5.6.22]# rm -f CMakeCache.txt
[root@host2 mysql-5.6.22]#
[root@host2 mysql-5.6.22]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
。。。
-- Looking for iswctype - found
-- Check size of wchar_t
-- Check size of wchar_t - done
-- Check size of wctype_t
-- Check size of wctype_t - done
-- Check size of wint_t
-- Check size of wint_t - done
-- Found Curses: /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Performing Test HAVE_DECL_TGOTO
-- Performing Test HAVE_DECL_TGOTO - Success
-- Looking for strvis
-- Looking for strvis - not found
-- Looking for strunvis
-- Looking for strunvis - not found
-- Performing Test HAVE_WVLA
-- Performing Test HAVE_WVLA - Success
-- Using cmake version 2.8.12.2
-- Not building NDB
-- Looking for include file libaio.h
-- Looking for include file libaio.h - not found
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - not found
-- Looking for sched_getcpu
-- Looking for sched_getcpu - found
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE - Success
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS_64 - Success
-- Performing Test HAVE_IB_GCC_SYNC_SYNCHRONISE
-- Performing Test HAVE_IB_GCC_SYNC_SYNCHRONISE - Success
-- Performing Test HAVE_IB_GCC_ATOMIC_THREAD_FENCE
-- Performing Test HAVE_IB_GCC_ATOMIC_THREAD_FENCE - Failed
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Looking for asprintf
-- Looking for asprintf - found
-- Check size of pthread_t
-- Check size of pthread_t - done
-- 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://example.com:80
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- 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
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
MYSQL_USER
WITH_MEMORY_STORAGE_ENGINE
WITH_READLINE
-- Build files have been written to: /root/backup/mysqlsrc/mysql-5.6.22
[root@host2 mysql-5.6.22]#
12
编译代码,这一步时间有些长
[root@host2 mysql-5.6.22]# make
13
安装
[root@host2 mysql-5.6.22]# make install
14
扫一下结果
[root@host2 ~]# ll /usr/local/mysql/
total 168
drwxr-xr-x. 2 root root 4096 Jan 21 00:24 bin
-rw-r--r--. 1 root root 17987 Nov 21 13:39 COPYING
drwxr-xr-x. 3 root root 4096 Jan 21 00:24 data
drwxr-xr-x. 2 root root 4096 Jan 21 00:24 docs
drwxr-xr-x. 3 root root 4096 Jan 21 00:24 include
-rw-r--r--. 1 root root 101760 Nov 21 13:40 INSTALL-BINARY
drwxr-xr-x. 3 root root 4096 Jan 21 00:24 lib
drwxr-xr-x. 4 root root 4096 Jan 21 00:24 man
drwxr-xr-x. 10 root root 4096 Jan 21 00:25 mysql-test
-rw-r--r--. 1 root root 2496 Nov 21 13:39 README
drwxr-xr-x. 2 root root 4096 Jan 21 00:24 scripts
drwxr-xr-x. 28 root root 4096 Jan 21 00:25 share
drwxr-xr-x. 4 root root 4096 Jan 21 00:25 sql-bench
drwxr-xr-x. 2 root root 4096 Jan 21 00:25 support-files
[root@host2 ~]# ll /usr/local/mysql/data/
total 4
drwxr-xr-x. 2 root root 4096 Jan 21 00:24 test
[root@host2 ~]#
###################
安装后的目录和二进制包安装是一样的
Table 2.3 MySQLInstallation Layout for Generic Unix/Linux Binary Package
Directory |
Contentsof Directory |
bin |
Clientprograms and the mysqldserver |
data |
Logfiles, databases |
docs |
Manualin Info format |
man |
Unixmanual pages |
include |
Include(header) files |
lib |
Libraries |
scripts |
mysql_install_db |
share |
Miscellaneoussupport files, including error messages, sample configurationfiles, SQL for database installation |
sql-bench |
Benchmarks |
15
清除临时文件
[root@host2 mysql-5.6.22]# make clean
16
修改目录属主数组
[root@host2 mysql-5.6.22]# chown -R mysql:mysql /usr/local/mysql/data
[root@host2 mysql-5.6.22]# chown -R mysql:mysql /usr/local/mysql
17
创建MySQL Server系统表
[root@host2 mysql-5.6.22]# cd /usr/local/mysql/
[root@host2 mysql]#scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...2015-01-21 00:43:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-21 00:43:18 25208 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-21 00:43:18 25208 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-21 00:43:18 25208 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-21 00:43:18 25208 [Note] InnoDB: Memory barrier is not used
2015-01-21 00:43:18 25208 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-21 00:43:18 25208 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-21 00:43:18 25208 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-21 00:43:18 25208 [Note] InnoDB: Completed initialization of buffer pool
2015-01-21 00:43:18 25208 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-01-21 00:43:18 25208 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-01-21 00:43:18 25208 [Note] InnoDB: Database physically writes the file full: wait...
2015-01-21 00:43:18 25208 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-01-21 00:43:18 25208 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-01-21 00:43:18 25208 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-01-21 00:43:18 25208 [Warning] InnoDB: New log files created, LSN=45781
2015-01-21 00:43:18 25208 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-01-21 00:43:18 25208 [Note] InnoDB: Doublewrite buffer created
2015-01-21 00:43:18 25208 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-21 00:43:18 25208 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-01-21 00:43:18 25208 [Note] InnoDB: Foreign key constraint system tables created
2015-01-21 00:43:18 25208 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-01-21 00:43:18 25208 [Note] InnoDB: Tablespace and datafile system tables created.
2015-01-21 00:43:18 25208 [Note] InnoDB: Waiting for purge to start
2015-01-21 00:43:19 25208 [Note] InnoDB: 5.6.22 started; log sequence number 0
2015-01-21 00:43:19 25208 [Note] Binlog end
2015-01-21 00:43:19 25208 [Note] InnoDB: FTS optimize thread exiting.
2015-01-21 00:43:19 25208 [Note] InnoDB: Starting shutdown...
2015-01-21 00:43:20 25208 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2015-01-21 00:43:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-21 00:43:20 25230 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-21 00:43:20 25230 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-21 00:43:20 25230 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-21 00:43:20 25230 [Note] InnoDB: Memory barrier is not used
2015-01-21 00:43:20 25230 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-21 00:43:20 25230 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-21 00:43:20 25230 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-21 00:43:20 25230 [Note] InnoDB: Completed initialization of buffer pool
2015-01-21 00:43:20 25230 [Note] InnoDB: Highest supported file format is Barracuda.
2015-01-21 00:43:20 25230 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-21 00:43:20 25230 [Note] InnoDB: Waiting for purge to start
2015-01-21 00:43:20 25230 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
2015-01-21 00:43:20 25230 [Note] Binlog end
2015-01-21 00:43:20 25230 [Note] InnoDB: FTS optimize thread exiting.
2015-01-21 00:43:20 25230 [Note] InnoDB: Starting shutdown...
2015-01-21 00:43:21 25230 [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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h host2 password 'new-password'
Alternatively you can run:
./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 . ; ./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 ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[root@host2 mysql]#
[root@host2 mysql]# scripts/mysql_install_db --help
Usage: scripts/mysql_install_db [OPTIONS]
--basedir=path The path to the MySQL installation directory.
--builddir=path If using --srcdir with out-of-directory builds, you
will need to set this to the location of the build
directory where built files reside.
--cross-bootstrap For internal use. Used when building the MySQL system
tables on a different host than the target.
--datadir=path The path to the MySQL data directory.
If missing, the directory will be created, but its
parent directory must already exist and be writable.
--defaults-extra-file=name
Read this file after the global files are read.
--defaults-file=name Only read default options from the given file name.
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
use hostnames will use IP addresses.
--help Display this help and exit.
--ldata=path The path to the MySQL data directory. Same as --datadir.
--no-defaults Don't read default options from any option file.
--keep-my-cnf Don't try to create my.cnf based on template.
Useful for systems with working, updated my.cnf.
Deprecated, will be removed in future version.
--random-passwords Create and set a random password for all root accounts
and set the "password expired" flag,
also remove the anonymous accounts.
--rpm For internal use. This option is used by RPM files
during the MySQL installation process.
--skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
--srcdir=path The path to the MySQL source directory. This option
uses the compiled binaries and support files within the
source tree, useful for if you don't want to install
MySQL yet and just want to create the system tables.
--user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
Any other options are passed to the mysqld program.
[root@host2 mysql]#
18
把初始化生成的 /usr/local/mysql/my.cnf 配置文件的属主数组更改为mysql:
[root@host2 mysql]# ll
total 172
drwxr-xr-x. 2 mysql mysql 4096 Jan 21 00:24 bin
-rw-r--r--. 1 mysql mysql 17987 Nov 21 13:39 COPYING
drwxr-xr-x. 5 mysql mysql 4096 Jan 21 00:43 data
drwxr-xr-x. 2 mysql mysql 4096 Jan 21 00:24 docs
drwxr-xr-x. 3 mysql mysql 4096 Jan 21 00:24 include
-rw-r--r--. 1 mysql mysql 101760 Nov 21 13:40 INSTALL-BINARY
drwxr-xr-x. 3 mysql mysql 4096 Jan 21 00:24 lib
drwxr-xr-x. 4 mysql mysql 4096 Jan 21 00:24 man
-rw-r--r--. 1 root root 943 Jan 21 00:43 my.cnf
drwxr-xr-x. 10 mysql mysql 4096 Jan 21 00:25 mysql-test
-rw-r--r--. 1 mysql mysql 2496 Nov 21 13:39 README
drwxr-xr-x. 2 mysql mysql 4096 Jan 21 00:24 scripts
drwxr-xr-x. 28 mysql mysql 4096 Jan 21 00:25 share
drwxr-xr-x. 4 mysql mysql 4096 Jan 21 00:25 sql-bench
drwxr-xr-x. 2 mysql mysql 4096 Jan 21 00:25 support-files
[root@host2 mysql]#
[root@host2 mysql]# chown -R mysql:mysql /usr/local/mysql
19
配置启动脚本
[root@host2 mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
20
启动MySQL
[root@host2 mysql]# /etc/init.d/mysql status
ERROR! MySQL is not running
[root@host2 mysql]# /etc/init.d/mysql start
Starting MySQL.. SUCCESS!
[root@host2 mysql]# netstat -anpl | grep mysql
tcp 0 0 :::3306 :::* LISTEN 25391/mysqld
unix 2 [ ACC ] STREAM LISTENING 241269 25391/mysqld /usr/local/mysql/mysql.sock
[root@host2 mysql]#
21
配置环境变量(看需要,可以vi /etc/profile)
[root@host2 ~]# vi /root/.bash_profile
在后面追加:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
[root@host2 ~]# source /root/.bash_profile
22
在17步初始化数据库时有如下提示,就是修改root用户密码,据需可以mysql_secure_installation
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h host2 password 'new-password'
Alternatively you can run:
./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.
mysql -u root mysql
mysql>use mysql;
mysql>desc user;
# mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力,据需谨慎操作。
mysql>update user set password = password('123456') where User='root';
mysql>select host,user,password from user where User='root';
mysql>flush privileges;
mysql> \q
Bye
[root@host2 ~]#
据需dorp test数据库和匿名用户,建议生产服务器实施:
mysql> select host , user, password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| host2 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 127.0.0.1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| ::1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost | | |
| host2 | | |
+-----------+------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
23
根据需要设置开机自动启动服务
chkconfig mysql on
#24
#可以编辑hosts文件,加入本机IP和主机名,共备用 dns解析用
#vi /etc/hosts
#192.168.10.101 dbtdiv.com
参考
http://dev.mysql.com/doc/refman/5.6/en/installing.html
-----------------
转载请著明出处:
blog.csdn.net/beiigang