Compile and install mysql 5.6 in CentOS.

Source: Internet
Author: User

I just activated the machine. I was prepared to compile and install lnmp and found that mysql would not compile. I was a little depressed. It turns out that cmake has been used for installation in mysql since mysql 5.5. (Although the one-click installation of lnmp package and yum method are available, I don't like it very much, but I still have high customization ).

Hurry up and find a method on the Internet. record it.

First, check whether cmake is installed.

Yum install cmake

After confirmation, configure

# Adding users and changing Permissions

Groupadd mysql
Useradd-s/sbin/nologin-M-g mysql
Mkdir-p/home/mysql/
Mkdir-p/home/mysql/data/
Mkdir-p/home/mysql/log/
Chown-R mysql: mysql/home/mysql/

# Configuration

Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/home/mysql/data \
-DMYSQL_USER = mysql \
-DWITH_SSL = yes \
-DMYSQL_TCP_PORT = 3306

The above is my configuration file. For more information about other parameters, see the official documentation:

  • -DCMAKE_INSTALL_PREFIX =/usr/local/mysql \ # installation directory
  • -DMYSQL_UNIX_ADDR =/tmp/mysql. sock \ # Unix socket file path. Customize this path to prevent Error Reporting
  • -DDEFAULT_CHARSET = gbk \ # default character
  • -DDEFAULT_COLLATION = gbk_chinese_ci \ # Check characters
  • -DEXTRA_CHARSETS = all \ # Install all extended character sets
  • -DWITH_MYISAM_STORAGE_ENGINE = 1 \ # Install the myisam storage engine
  • -DWITH_INNOBASE_STORAGE_ENGINE = 1 \ # Install the innodb Storage Engine
  • -DWITH_ARCHIVE_STORAGE_ENGINE = 1 \ # Install the archive storage engine
  • -DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \ # Install the blackhole storage engine
  • -DWITH_MEMORY_STORAGE_ENGINE = 1 \ # Install the memory storage engine
  • -DWITH_FEDERATED_STORAGE_ENGINE = 1 # Install the frderated storage engine
  • -DWITH_READLINE = 1 \ # shortcut key function
  • -DENABLED_LOCAL_INFILE = 1 \ # Allow Local Data Import
  • -DMYSQL_DATADIR =/usr/local/mysql/data \ # database storage directory
  • -DMYSQL_USER = mysql \ # database owner
  • -DMYSQL_TCP_PORT = 3306 \ # Database Port
  • -DSYSCONFDIR =/etc \ # MySQL configuration file
  • -DWITH_SSL = yes # Database SSL

After configuration is complete

Make

Make install

5.6.12 and later, the my. default. cnf file is officially provided, so the configuration should be resolved by yourself.

After the configuration is complete, install the initial database

Chmod + w/usr/local/mysql
Chown-R mysql: mysql/usr/local/mysql
Ln-s/usr/local/mysql/lib/libmysqlclient. so.16/usr/lib/libmysqlclient. so.16

Cd/usr/local/mysql
Scripts/mysql_install_db -- user = mysql -- datadir =/home/mysql/data


Cp support-files/mysql. server/etc/init. d/mysql. server


Manual start
/Etc/init. d/mysql. server start

Change Password
/Usr/local/mysql/bin/mysqladmin-u root password 'root'

Installation Complete

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.