MySQL source installation under Linux (CentOS or Radhat)

Source: Internet
Author: User

Installation Environment:

CentOS6.3 64-bit

Software:

Mysql-5.6

Required Packages:

gcc/g++:MySQL 5.6to start, you need to useg++to compile.
CMake:MySQL 5.5Start, useCMakefor project Management,CMakeneed to2.8The above version.
Bison:MySQLThe syntax parser needs to use theBisonto compile.
Ncurses-devel: A development package for terminal operations.
Zlib:MySQLUsezlibto compress

For Library Package Downloads:

can go to the official website to download, you can also go to the network disk download

Http://pan.baidu.com/s/1nuOm0fn

for MySQL compilation parameters:
Cmake_build_typecompiled version type:Relwithdebinfoand theDebug, the difference isRelwithdebinfowill be optimized.
Cmake_install_prefixSpecifyMake Installthe target path of the installation.
SysconfdirSpecifies the default path for the configuration file.
Mysql_datadirSpecifyDatathe default path for the directory.
With_debugSpecifies whether there areDebugginginformation, commonly used for source debugging, openWith_debug, the production environment is closed.
Enabled_profilingSpecifies whether you can useShow Profiledisplays detailed information about the operation execution.
Default_charsetSpecifies the default character set, which can be specified in the startup configuration file.
Default_collationSpecifies the default character comparison and sorting rules.
With_extra_charsetsspecifies a different character set that may be used.
With_sslSpecifySSLthe type, from5.6.6Start Defaultbundledtype, you can also specifySSLThe path address of the library.
With_zlibSpecifyzlibtype that is used for compression functions.
Enabled_local_infileSpecifies whether to allow the use ofLoad Data infilefunction.
With_embedded_serverSpecifies whether to compileLibmysqldembedded Libraries.
Install_layoutSpecifies the layout type of the installation.
With_storage_storage_engineSpecifies the storage engine supported by the compilation, supported by defaultMyISAM,MERGE,MEMORY,CSVstorage engine.

Compile and install:

1. Install the necessary libraries

Continue installation with Yum

GCC-related packages: Yum install gcc*

Yum Install Bison

Yum Install Ncurses-devel

Yum Install zlib

CMake because the CMake version in CentOS6.3 Yum is 2.6 and the installation of MySQL requires more than 2.8 of the version so CMake is compiled and installed by source code

(1) CMake Installation:

This installation is based on the cmake-2.8.5.tar.gz version of the package

-zxvf cmake-2.8. 5 . TAR.GZCD CMake - 2.8. 5 . / Configuremakemake Install

Enter CMake--version command after all success

If the result is: CMake version 2.8.5 the CMake installation succeeds.

PS: If there is no cmake command, copy the cmake under the bin to /usr/bin/

2.MySQL Installation

MySQL Source installation package: (this time installing MySQL 5.6.30 version)

Mysql-5.6.30.tar.gz

Tar-ZXVF MySQL-5.6. -. TAR.GZCD MySQL-5.6.30
#创建mysql目录mkdir-P/Mysql/mkdir-P/Mysql/Dategroupadd Mysqluseradd-R-g MySQL Mysqlcmake. -Dcmake_install_prefix=/Mysql-Dmysql_datadir=/Mysql/Data-Ddefault_charset=Utf8-Ddefault_collation=Utf8_general_ci-Dextra_charsets=all -Denabled_local_infile=1Makemake Install

MySQL Installation parameter description:

-dcmake_install_prefix------------------------ installation directory

-dinstall_datadir------------------------- Database storage directory

-ddefault_charset--------------------------- use UTF8 characters

-ddefault_collation---------------------------- Check character

-dextra_charsets-------------------- Install all extended character sets

-denabled_local_infile------------ allow data to be imported locally

PS: If you need to recompile, you need to old object file and cache information

--/etc/my.cnf

After the compilation installation is complete

To start the MySQL service:

- /  -/mysql/date//mysqlscripts/ -- User=mysqlCP support-files//etc/init.d/mysqld

Vi/root/.bash_profile

Add a line at the end

Path= $PATH: $HOME/bin:/mysql/bin:/mysql/lib

So far, the MySQL installation is complete.

Finally we start the MySQL service:

Service mysqld Start

(The service name is based on the name of the CP support-files/mysql.server/etc/init.d/mysqld copy of the past)

Show starting MySQL: success! The startup succeeds

Modify the root user password to modify remote login permissions:

Log in to MySQL database

Mysql-uroot

#一开始默认密码为空

If the error 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' ERROR

Here's how to fix it

Check the wrong information first to find the location of Mysql.sock, this time is located in/tmp/mysql.sock

Modify the My.cnf file

Vi/etc/my.cnf

Modify the socket directory in the mysqld to the/tmp/mysql.sock directory.

Then restart the service

Service mysqld Restart

Log in to the MySQL database again

Mysql-uroot

After logging in

Use MySQL; #选取数据库
GRANT all privileges on * * to [email protected] '% ' identified by ' root '; #赋予远程登录权限
Update user Set Password = Password (' ********* ') where user= ' root '; Replace the #修改root密码 ******* with the required password
Flush privileges; #提交操作

Then the root user will need a password to log in to the MySQL database.

PS: Remote Login If unable to log in to check if the server firewall is down

PS: If you cannot connect remotely and the error is incorrect mysql error number 1130, then add the following statement to try:

Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' ****** ' with GRANT OPTION;

MySQL source installation under Linux (CentOS or Radhat)

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.