mysql5.6 Compiling and installing detailed

Source: Internet
Author: User
Tags chmod mysql download

1. Download the installation package tar.gz

MySQL Download official website--mysql Community Server 5.6.26--source code--

--generic Linux (Architecture independent), compressed TAR Archive (. tar.gz)

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz


2. After the download is completed, check the MD5 of the file, and confirm that the download is original, in case of tampering.

#md5sum mysql5.6.26.tar.gz


3. Installing CMake

Yum-y Install CMake


4. Check if MySQL is already installed

#rpm-qa |grep MySQL

Some words to uninstall the previously installed MySQL

#rpm-e--nodeps xxx

(-IVH install RPM package parameters, is installed in verbose mode, you can display the progress bar,--nodeps do not consider the dependent relationship, mandatory installation or uninstallation;--force mandatory)

Delete the related configuration file

#rm/etc/my.cnf


5. Install the required packages for the compiled code (BISON,GCC-C++,NCURSES,LIBAIO)

Yum Install-y ncurses-devel.x86_64
Yum Install-y libaio.x86_64
Yum Install-y bison.x86_64
Yum Install-y gcc-c++.x86_64

If it is not installed, the CMake will be reported in the compile phase:

a.--Could not find Curses (missing:curses_library curses_include_path)
CMake Error at cmake/readline.cmake:85 (MESSAGE):
Curses Library not found. Please install the appropriate package,

--No ncurses installed

B.cmake Error at/usr/share/cmake-2.8/modules/cmakecxxinformation.cmake:37 (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

--No gcc-c++ installed

C. After installing the appropriate compilation package, you need to delete the previous CMakeCache.txt file

#find/-name CMakeCache.txt

#rm-rf/usr/local/.../cmakecache.txt


6.cmake performing compilation

#cd/.. /mysql-5.6.26

#time CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql/data-dwith_innobase_storage_engine=1-dmysql _unix_addr==/data/mysql/mysql.sock-dmysql_user=mysql-ddefault_charset=utf8-ddefault_collation=utf8_general_ci

650) this.width=650; "src=" Http://www.linuxidc.com/upload/2015_06/150629220966763.png "width=" 581 "vspace=" 5 "style = "Border:0px;color:rgb (51,51,51); Font-family:tahoma, ' song-body '; font-size:14px;line-height:22px;text-align:justify; White-space:normal;background-color:rgb (250,250,252); "/>

The compilation is displayed successfully

7.make && make install MySQL

#make && make Install

Take a long time.


8. Configure MySQL to create users and user groups

Check whether to create a MySQL user:

#cat/etc/passwd |grep MySQL

#cat/etc/shadow |grep MySQL

If it does not exist:

#groupadd mysql-s/sbin/nologin to create a MySQL user group, but cannot log on to the system

#useradd-G MySQL MySQL created by MySQL user group is the MySQL user group

Or

#groupadd MySQL

#useradd-R-G MySQL Mysql-r indicates that the MySQL user is a system user and is not available for login system

Or

#groupadd MySQL

#useradd mysql-g mysql-m-s/sbin/nologin

-G indicates the user group to which the new user belongs

-M indicates that the root directory is not established

-S defines the shell,/sbin/nologin used to indicate that the system cannot be logged


9. Creating a database path and granting permissions

#mkdir-p/data/mysql-p means to create a directory recursively

#chown-R Mysql.mysql/data/mysql

#chmod 755/data/mysql


#chown-R Mysql.mysql/usr/local/mysql


10. Initializing the database

#cd/usr/local/mysql

#cp support-files/my-default.cnf/etc/my.cnf

#scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql

(Executed mysql_install_db script that initializes the data directory in MySQL and establishes a system table.) Note that the MySQL service process mysqld accesses the data directory, so it must be executed by the user who started the mysqld process (the MySQL user we previously specified), or by the root user, but the root user must add the parameters when performing the operation--user= Mysql. If the installation directory for MySQL is not/usr/local/mysql, you must also specify the directory parameter--basedir=/: /,--datadir=/. /)

If error:

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

2014-06-27 10:47:14 9686 [Note] Binlog End
2014-06-27 10:47:14 9686 [Note]/usr/local/mysql/bin/mysqld:shutdown complete

FIX: #mkdir-P/data/mysql/binlog/

#chown-R Mysql.mysql/data/mysql/binlog

Last hint:

Warning:default config FILE/ETC/MY.CNF exists on the system
This file is being read by default by the MySQL server
Either remove it, or use the want
--defaults-file argument to Mysqld_safe when starting the server

Indicates that initialization is complete.


11. Add boot entry and boot service Systemctl

#cp Supports-files/mysql.server/etc/init.d/mysqld

#chmod 700/etc/init.d/mysqld

#echo "Export path= $PATH:/usr/local/mysql/bin" >>/etc/profile setting environment variables

#source/etc/profile make the newly set environment variable effective immediately


#cd/lib/systemd/system

#vim Mysqld.service

[Unit]

Description=mysql

After=network.target

[Service]

Type=forking

Execstart=/www/lanmps/init.d/mysqld start

Execreload=/www/lanmps/init.d/mysqld restart

Execstop=/www/lanmps/init.d/mysqld stop

Privatetmp=true

[Install]

Wantedby=multi-user.target

Specific reference documents: SYSTEMCTL system service Management, Service,chkconfig

http://jasonzhu.blog.51cto.com/5594807/1692442


12.mysql service startup

#service mysqld Start

Or

#systemctl Start Msyqld.service



13. Verify that MySQL is turned on successfully

#ps aux |grep MySQL

Or

#nestat-LNP |grep 3306

Or

#mysql

>show databases;

Set the root user password for MySQL

#mysqladmin-uroot Password


If error 1:

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 has another MYSQLD server running on socket:/usr/local/mysql/mysql.sock ?
2014-06-24 14:56:54 31726 [ERROR] Aborting

Main reasons:

The/usr/local/mysql directory needs to give MySQL permission

Depending on the log file, check the run permissions to determine whether the Mysql.sock file is written to the/data/mysql/directory because it does not have permissions.

#chown-R Mysql.mysql/data/mysql

#chown-R Mysql.muysql/usr/local/mysql

If error 2:

。。。。

May be due to the existence of the MySQL process, so when you open the service error

Kill [PID] kills the corresponding process.


MySQL Multi-instance configuration: http://www.linuxidc.com/Linux/2015-06/119354.htm


mysql5.6 Compiling and installing detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.