MySQL detailed installation

Source: Internet
Author: User
Tags chmod

Three types of mounting options

12 binary decompression is used

2 yum/rpm is suitable for many server installation, after compiling, made RPM package for the YUM warehouse

3 Compile and install custom installation, the equivalent of DIY ... 5.1 Installation with make,5.5 installation to use CMake

Installation of binary explanation demo!!

Displays the system name, the node name, the operating system's release number, the operating system version, and the machine ID number of the running system.

[Email protected] ~]# uname-a
Linux sky-mysql 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 15:44:03 UTC x86_64 x86_64 x86_64 gnu/linux

Upload or download binary packages (website or online, there are many)

[Email protected] ~]# ll/home/sky00747/tools/

-rw-r--r--. 1 root root 186722932 Apr 2 mysql-5.5.32-linux2.6-x86_64.tar.gz

Unzip

[Email protected] tools]# Tar XF mysql-5.5.32-linux2.6-x86_64.tar.gz
[email protected] tools]# LL
Total 182352
Drwxr-xr-x. Root root 4096 Oct 22:41 mysql-5.5.32-linux2.6-x86_64
-rw-r--r--. 1 root root 186722932 Apr 2 mysql-5.5.32-linux2.6-x86_64.tar.gz

Copy it to the directory you want to put it in.

[[email protected] tools] #mkdir/application/

[Email protected] tools]# cp-r mysql-5.5.32-linux2.6-x86_64/application/

[[email protected] tools] #ln-S mysql-5.5.32-linux2.6-x86_64/./mysql #创建一个软连接

Template file

[Email protected] mysql]# CD support-files/

[email protected] support-files]# ll
Total
-rwxr-xr-x. 1 root root 1153 Oct 22:43 binary-configure
-rwxr-xr-x. 1 root root 4528 Oct 22:43 Config.huge.ini
-rwxr-xr-x. 1 root root 2382 Oct 22:43 Config.medium.ini
-rwxr-xr-x. 1 root root 1626 Oct 22:43 Config.small.ini
-rw-r--r--. 1 root root 773 Oct 22:43 Magic
-rw-r--r--. 1 root root 4691 Oct 22:43 my-huge.cnf
-rw-r--r--. 1 root root 19759 Oct 22:43 my-innodb-heavy-4g.cnf
-rw-r--r--. 1 root root 4665 Oct 22:43 my-large.cnf
-rw-r--r--. 1 root root 4676 Oct 22:43 my-medium.cnf
-rw-r--r--. 1 root root 2840 Oct 22:43 my-small.cnf
-rwxr-xr-x. 1 root root 1061 Oct 22:43 mysqld_multi.server
-rwxr-xr-x. 1 root root 839 Oct 22:43 mysql-log-rotate
-rwxr-xr-x. 1 root root 10880 Oct 22:43 mysql.server
-rwxr-xr-x. 1 root root 1326 Oct 22:43 Ndb-config-2-node.ini
drwxr-xr-x. 2 root root 4096 Oct 22:43 Solaris

Create a directory to hold the data file

[Email protected] ~]# Mkdir/var/lib/mysql

Copy the template file (which is the configuration file) and copy it according to your own requirements. You can change it slowly.

[email protected] support-files]# CP my-large.cnf./my.cnf

This copy will have a lot of comments. According to your preferences ... I'm not going to comment.

Annotation parameters cat my-large.cnf|egrep-v "#|^$" >/etc/my.cnf

Vim MY.CNF

in [mysqld]

Add DataDir =/var/lib/mysql

CP./my.cnf/var/lib/mysql

#默认是可以拷贝到/etc/my.cnf

Create a MySQL user, but not allow this user to log in

[Email protected] support-files]# useradd mysql-s/sbin/nologin-m

Authorizing a directory to MySQL users and groups

[Email protected] support-files]# chown-r mysql.mysql/var/lib/mysql/
[Email protected] support-files]# ll/var/lib/mysql/
Total 8
-rw-r--r--. 1 mysql mysql 4689 Oct 23:25 my.cnf

Configuring Startup files

[email protected] support-files]# CP mysql.server/etc/init.d/mysqld

Initialize (the table that produces MySQL)

./scripts/mysql_install_db--defaults-file=/var/lib/mysql/my.cnf--user=mysql

Start MySQL

Can be done by/etc/init.d/mysqld start

There is also a

[Email protected] mysql]# cd/application/mysql/bin/

[Email protected] Mysql]#./bin/mysqld_safe &

If the my.cnf is under/etc/, it can be started. But our config file is under/var/lib/mysql/, we need to specify the file.

[Email protected] Mysql]#./bin/mysqld_safe--DEFAULTS-FILE=/VAR/LIB/MYSQL/MY.CNF &

See if it starts

View ports

[Email protected] bin]# Ss-lntup |grep 3306
TCP LISTEN 0 *:3306 *:* Users: (("mysqld", 27975,11))

View Tasks

[Email protected] bin]# Ps-ef |grep mysqld
Root 27697 27448 0 23:56 pts/0 00:00:00/bin/sh./mysqld_safe--defaults-file=/var/lib/mysql/my.cnf
MySQL 27975 27697 1 23:56 pts/0 00:00:00/usr/local/mysql/bin/mysqld--defaults-file=/var/lib/mysql/my.cnf--basedir=/ Usr/local/mysql--datadir=/var/lib/mysql--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/var/ Lib/mysql/sky-mysql.err--pid-file=/var/lib/mysql/sky-mysql.pid--socket=/tmp/mysql.sock--port=3306

Start MySQL

[Email protected] bin]# echo ' export path=/application/mysql/bin: $PATH ' >>/etc/profile
[Email protected] bin]# tail-1/etc/profile
Export Path=/application/mysql/bin: $PATH
[Email protected] bin]# Source/etc/profile

You can start MySQL directly by adding environment variables.

[[email protected] bin]# MySQL
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server Version:5.5.32-log MySQL Community Server (GPL)

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

=============================== Compiling and installing =====================

Installation 5.5

Check for dependent packages

Yum Install Ncurses-devel libaio-devel-y

Rpm-qa Ncurses-devel Libaio

if installing 5.5 requires a software cmake

Https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz

Tar XF cmake-3.6.3.tar.gz

CD cmake-3.6.3.tar.gz

./configure

Gmake

Gmake Install

========== installation mysql===========

Create user

Useradd mysql-s/sbin/nologin-m

CD mysql-5.5.32

Compile

CD mysql-5.5.32

Compile

CMake. -dcmake_install_prefix=/application/mysql-5.5.32 \

-dmysql_datadir=/application/mysql-5.5.32/data \

-dmysql_unix_addr=/application/mysql-5.5.32/tmp/mysql.sock \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-DEXTRA_CHARSETS=GBK,GB2312,UTF8,ASCII \

-denabled_local_infile=on \

-dwith_innobase_storage_engine=1 \

-dwith_federated_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-dwithout_example_storage_engine=1 \

-dwithout_partition_storage_engine=1 \

-dwith_fast_mutexes=1 \

-dwith_zlib=bundled \

-denabled-local_infile=1 \

-dwith_readline=1 \

-dwith_embedded_server=1 \

-dwith_debug=0

Make && make Install &

Ln-s/application/mysql-5-5.32//application/mysql

Installation Complete

Copy Template

CP SUPPORT-FILES/MY-SMALL.CNF/ETC/MY.CNF

Cp:overwrite '/etc/my.cnf '? Y

Configuring Environment variables

Echo ' Export path=/application/mysql/bin: $PATH ' >>/etc/profile

Tail-1/etc/profile

Source/etc/profile

Echo $PATH

/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Must be at the top of the line.

Chown-r mysql.mysql/application/mysql/data/

Chmod-r 1777/tmp/

Initialization

cd/application/mysql/scripts/

./mysql_install_db--basedir=/application/mysql/--datadir=/application/mysql/data/--user=mysql

INIT.D Startup scripts

CP Support-files/mysql.server/etc/init.d/mysqld

chmod +x/etc/init.d/mysqld

/etc/init.d/mysqld start

View ports

Netstat-lntup|grep 3306

TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 19011/mysqld

You can log in.

Start MySQL

MySQL detailed installation

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.