四.mysql
1.MySQL源码安装系统需求
Source Installation System Requirements
Installation of MySQL from source requires several
development tools. Some of these tools are needed no matter
whether you use a standard source distribution or a
development source tree. Other tool requirements depend on
which installation method you use.
To install MySQL from source, your system must have the
following tools, regardless of installation method:
* CMake, which is used as the build framework on all
platforms. CMake can be downloaded from http://www.cmake.org.
* A good make program. Although some platforms come with
their own make implementations, it is highly recommended
that you use GNU make 3.75 or newer. It may already be
available on your system as gmake. GNU make is available
from http://www.gnu.org/software/make/.
* A working ANSI C++ compiler. GCC 4.4.6 or later, Clang
3.3 or later (FreeBSD and OS X), Visual Studio 2013 or
later, and many current vendor-supplied compilers are
known to work.
* Perl is needed if you intend to run test scripts. Most
Unix-like systems include Perl. On Windows, you can use a
version such as ActiveState Perl.
2.检查系统包版本
1) cmake
[iyunv@mdb01 cmake-3.3.2]# cmake --version
cmake version 3.3.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
[iyunv@mdb01 cmake-3.3.2]#
2) make
[iyunv@mdb01 cmake-3.3.2]# make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-redhat-linux-gnu
3) gcc
[iyunv@mdb01 cmake-3.3.2]# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
[iyunv@mdb01 cmake-3.3.2]#
4) perl
[iyunv@mdb01 cmake-3.3.2]# perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
Copyright 1987-2009, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
6.安装MySQL
[iyunv@mdb01 mysql-5.7.9]# make install
# End of source-build specific instructions
五、安装后配置
# Postinstallation setup
1.目录权限
shell> cd /opt/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
2.初始化数据库
shell> bin/mysql_install_db --user=mysql # Before MySQL 5.7.6
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
执行结果:
[iyunv@mdb01 mysql]# bin/mysqld --initialize --user=mysql
2015-10-29T21:58:57.465483Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-10-29T21:58:59.889999Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-10-29T21:59:00.201432Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-10-29T21:59:00.398966Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 42ad8740-7e88-11e5-83de-000c29270868.
2015-10-29T21:59:00.406427Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2015-10-29T21:59:00.424627Z 1 [Note] A temporary password is generated for root@localhost: Ek&!sA9(qYds
[iyunv@mdb01 mysql]# ls
bin COPYING data docs include INSTALL-BINARY lib man mysql-test README share support-files
[iyunv@mdb01 mysql]#
3.证书相关
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
执行结果
[iyunv@mdb01 mysql]# bin/mysql_ssl_rsa_setup
Generating a 2048 bit RSA private key
.......+++
..........+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.........................................................................................................................................................................................+++
.+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.....................................+++
...................+++
writing new private key to 'client-key.pem'
-----
[iyunv@mdb01 mysql]#
4.目录权限修改
shell> chown -R root .
shell> chown -R mysql data
Basedir mysql user
[iyunv@mdb01 mysql-5.7.9]# cd /opt
[iyunv@mdb01 opt]# chown mysql mysql
[iyunv@mdb01 opt]# ll
total 4
drwxr-xr-x. 11 mysql mysql 4096 Oct 30 06:09 mysql
5.启动 MySQL
shell> bin/mysqld_safe --user=mysql &
六、首次登陆 MySQL
1.登录MySQL
[iyunv@rhel6 mysql]# bin/mysql -u root -p
Enter password: 安装时生成的临时密码(Ek&!sA9(qYds)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.9-log
Copyright (c) 2000, 2015, 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>
2.修改登录密码root密码
* As of MySQL 5.7.6, use ALTER USER:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3.配置启动项
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysqld
PATH环境变量
vi /etc/profile
.....
.....
unset i
unset pathmunge
export PATH=/opt/mysql/bin:$PATH