MySQL installation (for beginners)

Source: Internet
Author: User
Tags mysql version openssl iptables

Application system is CentOS 6.x MySQL version 5.1

The SELinux and iptables can be closed in advance.

[Email protected] ~]# chkconfig iptables off

[Email protected] ~]# chkconfig ip6tables off

[[email protected] ~]# /etc/init.d/iptables Stop

[[email protected] ~]# /etc/init.d/ip6tables Stop

[Email protected] ~]# sed-i "s/linux=.*/linux=disabled/g"/etc/selinux/config

If you want to take effect after you change selinux, you need to restart the server, reboot or Shutdown-r now


Yum install make apr* autoconf automake gcc gcc-c++ OpenSSL openssl-devel pcre-devel gd kernel keyutils patch perl ker Nel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-de Vel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 L Ibxml2-devel Patch


These are support packages in order to prevent the error ahead of Yum



1 Download MySQL database l to/usr/local/src/


[Email protected] tmp]# cd/usr/local/src/

[Email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz

Http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz

There may be an error: You may not have installed the Wget tool, executed the Yum install-y wget installation wget This tool, this way also note that the version of your system has 32-bit and 64-bit, according to its own version of the download the corresponding MySQL. Below I installed is 32 bit, the step is the same.

[[email protected] src]# ls

Mysql-5.1.73-linux-i686-glibc23.tar.gz

Download completed, the process may be a bit slow, may have a connection with their own speed.

[Email protected] src]# Du-sh mysql-5.1.73-linux-i686-glibc23.tar.gz

124M mysql-5.1.73-linux-i686-glibc23.tar.gz


2 Decompression

[Email protected] src]# tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz

[[email protected] src]# ls

Mysql-5.1.73-linux-i686-glibc23

Mysql-5.1.73-linux-i686-glibc23.tar.gz

[Email protected] src]# Du-sh mysql-5.1.73-linux-i686-glibc23

410M mysql-5.1.73-linux-i686-glibc23


3 Move the extracted data to the/usr/local/mysql

[Email protected] src]# MV Mysql-5.1.73-linux-i686-glibc23/usr/local/mysql


4 Build MySQL User

[[email protected] src]# useradd-s/sbin/nologin-m MySQL

Create a run MySQL user-s not login-M do not create home directory


5 Copy configuration file

[[email protected] mysql]# ls

Bin data include Lib Mysql-test scripts Sql-bench

COPYING docs install-binary man README share support-files

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

[[email protected] support-files]# ls

Binary-configure my-huge.cnf Mysqld_multi.server

Config.huge.ini my-innodb-heavy-4g.cnf Mysql-log-rotate

Config.medium.ini my-large.cnf mysql.server

Config.small.ini my-medium.cnf Ndb-config-2-node.ini

Magic MY-SMALL.CNF

[Email protected] support-files]# CAT/ETC/MY.CNF

(System created configuration file, not required, then directly overwrite on it)

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


6 Copy the startup script file and modify its properties

[[email protected] support-files]# ls

Binary-configure my-huge.cnf Mysqld_multi.server

Config.huge.ini my-innodb-heavy-4g.cnf Mysql-log-rotate

Config.medium.ini my-large.cnf mysql.server

Config.small.ini my-medium.cnf Ndb-config-2-node.ini

Magic MY-SMALL.CNF

[Email protected] support-files]# ls/etc/init.d/

Abrt-ccpp cgred kdump nfslock restorecond SMARTD

ABRTD cpuspeed killall ntpd rngd sshd

Abrt-oops crond Lvm2-lvmetad ntpdate rpcbind SSSD

Acpid cups lvm2-monitor Numad rpcgssd Sysstat

ATD functions Mdmonitor ODDJOBD RPCIDMAPD Udev-post

AUDITD Haldaemon messagebus portreserve RPCSVCGSSD winbind

AutoFS Halt netconsole postfix rsyslog ypbind

Blk-availability ip6tables Netfs Psacct Sandbox

Certmonger iptables Network quota_nld SASLAUTHD

Cgconfig irqbalance NFS Rdisc Single

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

[Email protected] support-files]# mkdir-p/data/mysql

(Create a separate/data/partition)

[Email protected] support-files]# chown-r mysql/data/mysql/

(change owner to MySQL)

[Email protected] support-files]# vi/etc/init.d/mysqld

# in THE/ETC/MY.CNF, ~/.my.cnf or other MySQL configuration files.

# If you change the base dir, you must also the change DataDir. These may get

# Overwritten by settings in the MySQL configuration files.

Basedir=/usr/local/mysql

datadir=/data/mysql/

[[email protected] support-files] #ll/etc/init.d/mysqld (View permissions)

-rwxr-xr-x. 1 root root 12511 April 8 17:00/etc/init.d/mysqld


7 Initializing the database

[Email protected] src]# cd/usr/local/mysql/

[[email protected] mysql]# ls

Bin data include Lib Mysql-test scripts Sql-bench

COPYING docs install-binary man README share Support-files



[Email protected] mysql]#/scripts/mysql_install_db--user=mysql --datadir=/data/mysql/

Initializing Libraries --user defines the owner of the database, the --datadir defines where the database is installed, and it is recommended to place the partition on a large space, which needs to be created on its own.

[[email protected] mysql]# echo $? (The result is 0, indicating that the running result is normal)

0


9 Add the startup script to the system service entry, and set the boot start, start MySQL

[Email protected] support-files]# chkconfig--add mysqld

[Email protected] support-files]# chkconfig mysqld on

[Email protected] support-files]# chkconfig--list |grep mysqld

Mysqld 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

[[email protected] mysql]# /etc/init.d/mysqld start

Starting MySQL. success!


10 launch success Let's check it out.

[Email protected] profile.d]# NETSTAT-LNP

Active Internet connections (only servers)

Proto recv-q send-q Local address Foreign address State Pid/program Name

TCP 0 0 0.0.0.0:3306 0.0.0.0:*

Check the port 3306 OK

[Email protected] mysql]# /usr/local/mysql/bin/mysql

Welcome to the MySQL Monitor. Commands End With; or \g.


Your MySQL Connection ID is 1

Server Version:5.1.73-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> quit

Login OK, because it is the source package installation, the path of the landing is too long, after the use of the time is very troublesome, here we change

11 Extended Knowledge

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

Create a new path file and add the following:

#!/bin/bash


Export path= $PATH:/usr/local/mysql/bin

Save, exit. OK direct input MySQL haha success

[[email protected] ~]# MySQL

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 1

Server Version:5.1.73-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>

Here, my MySQL installation is complete thank you

MySQL installation (for beginners)

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.