MySQL getting started

Source: Internet
Author: User

MySQL getting started

Operating System: CentOS 6.7
MySQL version: 5.6.30

  • 1. Preparations
  • 2. System Configuration
  • 3. CMake compilation Configuration
  • 4. make & make install
  • 5. Subsequent configuration and Testing
  • Reference
1. Preparations

First, you need CMake. you can install yum directly:

yum install cmake

You can also official website https://cmake.org/download source code compilation.
I have selected the latest official website cmake-3.5.2.tar.gz.

# Tar-zxvf cmake-3.5.2.tar.gz & cd cmake-3.5.2 #./configure partial output omitted. -- Build files have been written to:/soft/cmake-3.5.2 --------------------------------------------- CMake has bootstrapped. Now run gmake. # gmake # make install
2. System Configuration

Add group and user:

groupadd mysqluseradd -g mysql mysql

Add the following content at the end of the vi/etc/security/limits. conf file:

mysql   soft    nproc   2047mysql   hard    nproc   16384mysql   soft    nofile  1024mysql   hard    nofile  65536
3. CMake compilation Configuration

Decompress the source package:

tar zxvf mysql-5.6.30.tar.gz && cd mysql-5.6.30

CMake compilation Configuration

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \-DCOMPILATION_COMMENT='JSS for mysqltest' \-DWITH_READLINE=ON \-DSYSCONFDIR=/data/mysqldata/3306 \-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

The following error occurs,

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:85 (MESSAGE):  Curses library not found.  Please install appropriate package,      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on RedHat and derivates it is ncurses-devel.Call Stack (most recent call first):  cmake/readline.cmake:128 (FIND_CURSES)  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)  CMakeLists.txt:421 (MYSQL_CHECK_EDITLINE)-- Configuring incomplete, errors occurred!See also "/soft/mysql-5.6.30/CMakeFiles/CMakeOutput.log".See also "/soft/mysql-5.6.30/CMakeFiles/CMakeError.log".[root@JY-DB mysql-5.6.30]# 

Yum installation prompt missing package:

yum install ncurses-devel

Delete the configuration file again:

rm -rf CMakeCache.txt

Then re-compile the CMake tool:

CMake Warning:  Manually-specified variables were not used by the project:    WITH_READLINE-- Build files have been written to: /soft/mysql-5.6.30[root@JY-DB mysql-5.6.30]# 
4. make & make install
[Root @ JY-DB mysql-5.6.30] # make & make install a large number of output slightly.

This takes a long time and is also related to machine performance.

5. Configure and test MySQL 5.1 later. Package the MySQL binary version:
[root@JY-DB data]# tar zcvf mysql-5.6.30.tar.gz /usr/local/mysql/
5.2 modify the directory owner of the MySQL software:
chown -R mysql.mysql /usr/local/mysql
5.3 modify mysql user environment variables:

Vi ~ /. Bash_profile

export LANG=zh_CN.GB18030export PATH=/usr/local/mysql/bin:$PATH
5.4 create a database service:
# mkdir -p /data/mysqldata/{3306/{data,tmp,binlog},backup,scripts}# chown -R mysql.mysql /data/mysqldata# su - mysql$ more /usr/local/mysql/support-files/my-default.cnf $ vi /data/mysqldata/3306/my.cnf

The content of my. cnf configuration file is as follows:

[client]port = 3306socket = /data/mysqldata/3306/mysql.sock#The MySQL Server[mysqld]port = 3306user = mysqlsocket = /data/mysqldata/3306/mysql.sockpid-file = /data/mysqldata/3306/mysql.pidbasedir = /usr/local/mysqldatadir = /data/mysqldata/3306/datatmpdir = /data/mysqldata/3306/tmpopen_files_limit = 10240explicit_defaults_for_timestampsql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES#Buffermax_allowed_packet = 256Mmax_heap_table_size = 256Mnet_buffer_length = 8ksort_buffer_size = 2Mjoin_buffer_size = 4Mread_buffer_size = 2Mread_rnd_buffer_size = 16M#Loglog-bin = /data/mysqldata/3306/binlog/mysql-binbinlog_cache_size = 32Mmax_binlog_cache_size = 512Mmax_binlog_size = 512Mbinlog_format = mixedlog_output = FILElog-error = ../mysql-error.logslow_query_log = 1slow_query_log_file = ../slow_query.loggeneral_log = 0general_log_file = ../general_query.logexpire-logs-days = 14#InnoDBinnodb_data_file_path = ibdata1:2048M:autoextendinnodb_log_file_size = 256Minnodb_log_files_in_group = 3innodb_buffer_pool_size = 1024M[mysql]no-auto-rehashprompt = (\u@\h)[\d]>\_default-character-set = gbk

Initialize the MySQL database:

$ /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql
5.5 start the Database Service:
mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

Test the connection and view the MySQL process and port listening status:

netstat -lnt | grep 3306ps -ef | grep bin/mysql | grep -v grep

The actual operation process is as follows:

[root@JY-DB ~]# su - mysql[mysql@JY-DB ~]$ mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.30-log JSS for mysqltestCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.(root@localhost)[(none)]> exitBye[mysql@JY-DB ~]$ netstat -lnt |grep 3306tcp        0      0 :::3306                     :::*                        LISTEN      [mysql@JY-DB ~]$  [mysql@JY-DB ~]$ ps -ef | grep bin/mysql | grep -v grepmysql     6736  1753  0 11:24 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnfmysql     7202  6736  0 11:24 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysqldata/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=10240 --pid-file=/data/mysqldata/3306/mysql.pid --socket=/data/mysqldata/3306/mysql.sock --port=3306
Reference
  • Li bingyang. Smear MySQL. Water Conservancy and hydropower press, 2014. For PDF download, see
  • Dev.mysql.com

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • 4
  • Next Page
[Content navigation]
Page 1: Install MySQL source code Page 2nd: MySQL binary quick deployment
Page 1: MySQL configuration security and ease of use Page 1: MySQL Master/Slave Configuration

Related Article

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.