Linux under the source installation mysql5.6

Source: Internet
Author: User
Tags chmod hosting

1. Download MySQL to/usr/local/src/

Cd/usr/local/src/wget Http://distfiles.macports.org/cmake/cmake-2.8.12.tar.gzwget http://ftp.ntu.edu.tw/MySQL/ Downloads/mysql-5.6/mysql-5.6.35.tar.gz

2. Compile and install CMake compile and install MySQL(the latest version requires cmake compilation installation)

[[email protected] src]# Tar-zxvfcmake-2.8.12.tar.gz[[email protected] src]# CD Cmake-2.8.12[[email protected] cmake-2.8.12]#./bootstrap

Log of errors:/usr/local/src/cmake-2.8.12/bootstrap.cmk/cmake_bootstrap.log

Workaround:


The environment required to install lamp

Yum-y install make gcc* gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel Bison ncurses-devel


After installing the required environment package, re-execute./bootstrap

[Email protected] cmake-2.8.12]#/bootstrap[[email protected] cmake-2.8.12]# echo $? 0[[email protected] cmake-2.8.12]# gmake[[email protected] cmake-2.8.12]# echo $?0[[email protected] cmake-2.8.12]# Gmake Install[[email protected] cmake-2.8.12]# echo $?0


3. Build MySQL User

[Email protected] src]# groupadd mysql[[email protected] src]# useradd-g mysql-s/sbin/nologin-m mysql[[email protected ] src]# ID mysqluid=500 (mysql) gid=500 (MySQL) groups=500 (MySQL)

4. Create a directory where the database resides, and authorize

[Email protected] mysql]# mkdir-p/data/mysql [[email protected] mysql]# chown-r Mysql.mysql/data/mysql/[[email    Protected] mysql]# chown-r mysql.mysql/usr/local/mysql/. Database installation path

5. Compile and install MySQL

[[email protected] src]# Tar-zxvfmysql-5.6.35.tar.gz[[email protected] src]# CD Mysql-5.6.35[[email protected] mysql-5.6.35]# Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=/data/mysql/mysql_3306.sock- Ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_extra_charsets=utf8,gbk-dwith_perfschema_ Storage_engine=1-dwith_federated_storage_engine=1\-dwith_partition_storage_engine=1-dwith_archive_storage_ eengine=1-dwith_readline=1-dmysql_datadir=/data/mysql/-dmysql_tcp_port=3306

Parameter description:

-dcmake_install_prefix #指定安装路径

-dmysql_unix_addr #数据库socket文件路径

-ddefault_charset #默认字符集

-ddefault_collation #默认编码

-dwith_extra_charsets #额外编码

-dwith_perfschema_storage_engine #启用PERFSCHEMA引擎支持

-dwith_federated_storage_engine #启用FEDERATED引擎支持

-dwith_partition_storage_engine #启用PARTITION引擎支持

-dwith_archive_storage_eengine #启用ARCHIVE引擎支持

-dwith_readline #使用readline功能

-dmysql_datadir #数据库数据存放目录

-dmysql_tcp_port #数据库TCP/IP Port

[[email protected] mysql-5.6.35]# echo $?0[[email protected] mysql-5.6.35]# make[[email protected] mysql-5.6.35]# echo $? 0[[email protected] mysql-5.6.35]# make Install[[email protected] mysql-5.6.35]# echo $?0


bin directory contains client tools and mysqld

Data directory holds database data files and log files

Docs Catalog contains User's Manual in info format

include directory contains mysql header files

Lib directory contains related lib libraries

mysql-test directory contains Some test script files for MySQL

Scripts directory holds mysql_install_db initialization Files

Share The directory holds various supporting files, including error messages, language encoding support,SQL installation scripts, and so on.

Sqlbench Directory hosting benchmark scripts

Support-file Directory hosting mysql profile template


6. Copy the MySQL configuration file to/etc/my.cnf

[[email protected] mysql]# Rm–f/etc/my.cnf[[email protected] mysql]# CD Support-files/[[email protected] support-files] # Lsbinary-configure Magic Mysqld_multi.server mysql-log-rotate mysql.server[[email protected] support-files]# cp/usr/ Local/mysql/support-files//etc/my.cnf


Edit the/ETC/MY.CNF configuration file, add the following line

 user = mysql                         //User  basedir = /usr/local/ mysql          //Basic Directory  datadir = /data/mysql                //Database Save Directory  port  = 3306              //Database Port  socket = /data/mysql/mysql_3306.sock                 log-error = /data/mysql/mysql_error.log      //Database error log file  pid-file = /data/mysql/mysql.pid             //database process consumes PID number    #内存使用限制  performance_schema_max_table_ Instances=400   table_definition_cache=400   table_open_cache=256 

7. Initialize the database

[Email protected] mysql]#/usr/local/mysql/scripts/mysql_install_db--user=mysql--datadir=/data/mysql/[[email                  Protected] mysql]# echo $? 0

a common problem with initializing a database: The system version is inconsistent with the database version, causing errors in initializing the database.

8. Copy MySQL boot script to/etc/init.d/mysqld

[Email protected] support-files]# Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld[[email Protected] support-files]# chmod +x/etc/init.d/mysqld


9. Join the startup MySQL service

[[email protected] mysql]# chmod +x/etc/init.d/mysqld[[email protected] mysql]# chkconfig--addmysqld[[email protected] mysql]# Chkconfig–level Mysqldon

10. Start the MySQL service

[[email protected] mysql]#/etc/init.d/mysqldstartstarting MySQL. [   ]

11, MSYQL service startup, view/data/mysql a few more files

[Email protected] mysql]# ls/data/mysql/auto.cnf ib_logfile0 mysql mysql_error.log performance_schemaibdata1 ib_l Ogfile1 mysql_3306.sock mysql.pid Test [[email protected] mysql]# netstat-lnapt |grepmysqld t CP 0 0::: 3306:::* LISTEN 3195/mysqld


12. Add Environment variables

[Email protected] ~]# vim/etc/profile.d/mysql.sh

#!/bin/bashexportpath= "$PATH:/usr/local/mysql/bin"

[Email protected] ~]# source/etc/profile.d/mysql.sh

13, the new addition of MySQL does not set the root password, you can set the root password by the following command:

#/usr/local/mysql/bin/mysqladmin-s/data/mysql/mysql_3306.sock-u root password ' new-password '

14. Log in to MySQL

[[email protected] ~]# MySQL

ERROR 2002 (HY000): Can ' tconnect to local MySQL server through socket '/tmp/mysql.sock ' (2)

Problem: Mysql.sock is not found in the/tmp directory, there are three ways to solve it:

1) /data/mysql/mysql_3306.sock do a soft link to/tmp/mysql.sock

Ln-s/data/mysql/mysql_3306.sock/tmp/mysql.sock

2) Modify the/ETC/MY.CNF to add the following line

[Client]

Socket =/data/mysql/mysql_3306.sock

3) Execute the following command to specify the socket connection file, Mysql–s/data/mysql/mysql_3306.sock

[Email protected] ~]# Mysql-s/data/mysql/mysql_3306.sock



This article is from "Xiao Yang" blog, please be sure to keep this source http://aqiang.blog.51cto.com/6086626/1895549

Linux under the source installation mysql5.6

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.