Summary of MYSQL Source Code Installation in MYSQL Learning Paper 001-LINUX Environment
In the past, MSSQL, ORACLE and SYBASE databases were mainly used, and recently MYSQL was used by the company.
Start learning by referring to the official document REFMAN-5.6-EN.A4.PDF. This paper is a summary of the recent installation process.
To install MYSQL5.6 with source code, the following tasks should be done:
2.1 Installation of LIBAIO
3.1 Download source code using GIT
4.1 Generating MAKEFILE Files with CMAKE
CMake is a cross-platform installation (compilation) tool that can describe the installation (compilation process) of all platforms in simple statements.
He can output various makefile s or project files and test the C++ features supported by the compiler.
Similar to automake under UNIX. CMake can compile source code, build libraries, generate wrapper s, and
Execution files can also be constructed in any order. CMake supports in-place construction (binaries and source code are in the same directory tree)
Build with out-of-place (binary files in other directories)
Therefore, it is easy to construct multiple binaries from the same source code catalog tree.
CMake also supports the construction of static and dynamic libraries.
4.2 Compile source code
5 Installation
5.1 Establishing Users and Groups
6 Configuration
6.1 Modify/etc/my.cnf
[root@FZ-Centos-23 mysql]# ln /usr/local/mysql/my.cnf /etc/my.cnf
[root@FZ-Centos-23 mysql]# vi /etc/my.cnf
6.2 Add to Service
Copy the file/usr/local/mysql/support-files/mysql.server to/etc/init.d and rename it mysqld.
And modify the basedir=/usr/local/mysql in the file
datadir=/usr/local/msyql/data
# chkconfig mysqld on
7 Start-up
Start learning by referring to the official document REFMAN-5.6-EN.A4.PDF. This paper is a summary of the recent installation process.
To install MYSQL5.6 with source code, the following tasks should be done:
1 Prepare Hardware (Virtual Machine), Operating System (CENTOS)
2 Installation of some tools and dependency libraries needed to compile source code
3 Download source code
4 Compile source code
5 Installation
6 Configuration
7 Start-up
The following is a detailed record of the installation process for later use.
1 Prepare Hardware (Virtual Machine), Operating System (CENTOS)2 Installation of some tools and dependency libraries needed to compile source code
3 Download source code
4 Compile source code
5 Installation
6 Configuration
7 Start-up
The following is a detailed record of the installation process for later use.
The virtual machine uses the account number assigned by the company. The operating system information is as follows:
# uname -a2 Installation of some tools and dependency libraries needed to compile source code
Linux FZ-Centos-23 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
2.1 Installation of LIBAIO
# yum install libaio
# yum search libaio2.2 Installation of BISON
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 5.4 MB 00:03
====================================================== N/S Matched: libaio ======================================================
libaio.i686 : Linux-native asynchronous I/O access library
libaio.x86_64 : Linux-native asynchronous I/O access library
libaio-devel.i686 : Development files for Linux-native asynchronous I/O access
libaio-devel.x86_64 : Development files for Linux-native asynchronous I/O access
Name and summary matches only, use "search all" for everything.
2.3 Install yum-y install gcc-c++ Autoconf make (abbreviated)
# yum install bison
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bison.x86_64 0:2.4.1-5.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================
Installing:
bison x86_64 2.4.1-5.el6 base 637 k
Transaction Summary
=================================================================================================================================
Install 1 Package(s)
Total download size: 637 k
Installed size: 2.0 M
Is this ok [y/N]: y
Downloading Packages:
bison-2.4.1-5.el6.x86_64.rpm | 637 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : bison-2.4.1-5.el6.x86_64 1/1
Verifying : bison-2.4.1-5.el6.x86_64 1/1
Installed:
bison.x86_64 0:2.4.1-5.el6
Complete!
Install the missing dependency tools or libraries as prompted at compile time.
3 Download source code (save in / usr/loca/src/mysql)3.1 Download source code using GIT
# git clone https://github.com/mysql/mysql-server.git3.2 View the current analysis with * as active
Initialized empty Git repository in /usr/local/src/mysql/mysql-server/.git/
remote: Counting objects: 1214340, done.
remote: Compressing objects: 100% (7/7), done.
Receiving objects: 100% (1214340/1214340), 1.01 GiB | 152 KiB/s, done.
remote: Total 1214340 (delta 0), reused 0 (delta 0), pack-reused 1214333
Resolving deltas: 100% (1005862/1005862), done.
[root@FZ-Centos-23 mysql-server]# pwd3.3 Set Branches to Active State
/usr/local/src/mysql/mysql-server
[root@FZ-Centos-23 mysql-server]# git branch -r
origin/5.5
origin/5.6
origin/5.7
origin/8.0
origin/HEAD -> origin/5.7
origin/cluster-7.2
origin/cluster-7.3
origin/cluster-7.4
origin/cluster-7.5
[root@FZ-Centos-23 mysql-server]# git branch
* 5.7
[root@FZ-Centos-23 mysql-server]# git checkout 5.63.4 New folder bld in source code mysql-server directory for compilation
Branch 5.6 set up to track remote branch 5.6 from origin.
Switched to a new branch '5.6'
[root@FZ-Centos-23 mysql-server]# git branch
* 5.6
5.7
mkdir bld4 Compile source code in source code
cd bld
4.1 Generating MAKEFILE Files with CMAKE
CMake is a cross-platform installation (compilation) tool that can describe the installation (compilation process) of all platforms in simple statements.
He can output various makefile s or project files and test the C++ features supported by the compiler.
Similar to automake under UNIX. CMake can compile source code, build libraries, generate wrapper s, and
Execution files can also be constructed in any order. CMake supports in-place construction (binaries and source code are in the same directory tree)
Build with out-of-place (binary files in other directories)
Therefore, it is easy to construct multiple binaries from the same source code catalog tree.
CMake also supports the construction of static and dynamic libraries.
]# cmake ../mysql-server/
-- Running cmake version 3.8.0-rc2
-- Found Git: /usr/bin/git (found version "1.7.1")
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
......
-- Using cmake version 3.8.0-rc2
-- Not building NDB
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googletest 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 https proxy: export https_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
-- Build files have been written to: /usr/local/src/mysql/bld
4.2 Compile source code
# make
Scanning dependencies of target gmock_main
[ 9%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/__/googletest/src/gtest-all.cc.o
[ 18%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o
[ 27%] Building CXX object googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[ 36%] Linking CXX static library libgmock_main.a
[ 36%] Built target gmock_main
Scanning dependencies of target gmock
[ 45%] Building CXX object googlemock/CMakeFiles/gmock.dir/__/googletest/src/gtest-all.cc.o
[ 54%] Building CXX object googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 63%] Linking CXX static library libgmock.a
[ 63%] Built target gmock
Scanning dependencies of target gtest
[ 72%] Building CXX object googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 81%] Linking CXX static library libgtest.a
[ 81%] Built target gtest
Scanning dependencies of target gtest_main
[ 90%] Building CXX object googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library libgtest_main.a
[100%] Built target gtest_main
5.1 Establishing Users and Groups
# groupadd mysql
# useradd -r -g mysql -s /bin/false mysql
Configuration, modifying the user properties of the installation path
cd /usr/local
chown -R mysql:mysql mysql
5.2 Installation# useradd -r -g mysql -s /bin/false mysql
Configuration, modifying the user properties of the installation path
cd /usr/local
chown -R mysql:mysql mysql
# make install5.3 Initialization data
-- Installing: /usr/local/mysql/sql-bench/test-connect
-- Installing: /usr/local/mysql/sql-bench/test-create
-- Installing: /usr/local/mysql/sql-bench/test-insert
-- Installing: /usr/local/mysql/sql-bench/test-select
-- Installing: /usr/local/mysql/sql-bench/test-transactions
-- Installing: /usr/local/mysql/sql-bench/test-wisconsin
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql
2017-03-29 18:31:42 4401 [Note] InnoDB: 5.6.35 started; log sequence number 1626027
2017-03-29 18:31:42 4401 [Note] Binlog end
2017-03-29 18:31:42 4401 [Note] InnoDB: FTS optimize thread exiting.
2017-03-29 18:31:42 4401 [Note] InnoDB: Starting shutdown...
2017-03-29 18:31:43 4401 [Note] InnoDB: Shutdown completed; log sequence number 1626037
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 FZ-Centos-23 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
6 Configuration
6.1 Modify/etc/my.cnf
[root@FZ-Centos-23 mysql]# ln /usr/local/mysql/my.cnf /etc/my.cnf
[root@FZ-Centos-23 mysql]# vi /etc/my.cnf
6.2 Add to Service
Copy the file/usr/local/mysql/support-files/mysql.server to/etc/init.d and rename it mysqld.
And modify the basedir=/usr/local/mysql in the file
datadir=/usr/local/msyql/data
# chkconfig mysqld on
7 Start-up
8 Initialize root password
service mysqld start
service mysqld stop
/usr/local/mysql/bin/mysqladmin -u root -h localhost password '123456'
or
mysql> use mysql
mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root';
root Password Forgetting Problem Handling
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor YES)
Solutions:
vi /etc/my.cnf
At [mysqld]
Add a line below
skip-grant-tables
Save exit and restart MYSQL
or
mysql> use mysql
mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root';
root Password Forgetting Problem Handling
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor YES)
Solutions:
vi /etc/my.cnf
At [mysqld]
Add a line below
skip-grant-tables
Save exit and restart MYSQL