Compile and install MySQL in CentOS

Source: Internet
Author: User
Tags localhost mysql

1. MySQL is an open-source small-scale associated database management system. The developer is MySQL AB in Sweden. MySQL is widely used in small and medium websites on the Internet. Because of its small size, fast speed, and low total cost of ownership, especially the open source code, many small and medium websites have chosen MySQL as their website database to reduce their total cost of ownership. If Linux is used as the operating system, Apache is used as the web server, and MySQL is used as the database, PHP/Perl/Python can be combined as a server-side script interpreter to form a stable, free, and powerful website system, the so-called LAMP combination, this article briefly introduces the installation and configuration of MySQL.

2. the MySQL installation process is as follows:


3. MySQL compilation and installation implementation:

Prepare the environment. Because the SQL data volume is growing fast, it is best to place the MySQL database on LVM for better expansion.

Create logical volumes to store Databases

[root@localhost ~] # ls -l /dev/sdb1 brw-rw---- 1 root disk 8, 17 Mar 12 00:19 /dev/sdb1 [root@localhost ~] # pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created [root@localhost ~] # vgcreate l23f /dev/sdb1 Volume group "l23f" successfully created [root@localhost ~] # lvcreate -L 2G -n l23 l23f Logical volume "l23" created [root@localhost ~] # lvs LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert l23 l23f -wi-a----- 2.00g root vg0 -wi-ao---- 20.00g swap vg0 -wi-ao---- 2.00g usr vg0 -wi-ao---- 10.00g var vg0 -wi-ao---- 20.00g

Format logical volumes

[root@localhost ~] # mke2fs -t ext4 /dev/l23f/l23

Prepare the database directory and mount the logical volume

[root@localhost ~] # mkdir -pv /data/mysqldata mkdir : created directory ` /data ' mkdir : created directory ` /data/mysqldata ' [root@localhost ~] # mount /dev/l23f/l23 /data/mysqldata

Download and decompress the file

[root@localhost ~] # lftp 172.16.0.1 lftp 172.16.0.1:~> cd pub /Sources/6 .x86_64 /mysql/ lftp 172.16.0.1: /pub/Sources/6 .x86_64 /mysql > ls -rw-r--r-- 1 0 0 186839926 Aug 22 2013 mysql-5.5.33-linux2.6-x86_64. tar .gz -rw-r--r-- 1 0 0 307062424 Aug 22 2013 mysql-5.6.13-linux-glibc2.5-x86_64. tar .gz -rw-r--r-- 1 0 0 307176769 Oct 07 05:26 mysql-5.6.14-linux-glibc2.5-x86_64. tar .gz lftp 172.16.0.1: /pub/Sources/6 .x86_64 /mysql > get mysql-5.5.33-linux2.6-x86_64. tar .gz 186839926 bytes transferred in 25 seconds (7.07M /s ) lftp 172.16.0.1: /pub/Sources/6 .x86_64 /mysql > bye [root@localhost ~] # ls -l mysql-5.5.33-linux2.6-x86_64.tar.gz -rw-r--r-- 1 root root 186839926 Aug 22 2013 mysql-5.5.33-linux2.6-x86_64. tar .gz [root@localhost ~] # tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/ [root@localhost ~] # ln -sv /usr/local/mysql-5.5.33-linux2.6-x86_64/ /usr/local/mysql ` /usr/local/mysql ' -> `/usr/local/mysql-5.5.33-linux2.6-x86_64/' [root@localhost ~] # cd /usr/local/ [root@localhost local ] # ls bin etc games include lib lib64 libexec mysql mysql-5.5.33-linux2.6-x86_64 sbin share src

Creating mysql users and groups is very insecure because the root permission is too large. You need to create a mysql user

[root@localhost local ] # groupadd mysql [root@localhost local ] # useradd -g mysql mysql [root@localhost local ] # id mysql uid=500(mysql) gid=500(mysql) groups =500(mysql) [root@localhost local ] #

Set permissions

[root@localhost mysql] # chown -R mysql:mysql ./* [root@localhost mysql] # chown -R :mysql /data/mysqldata/ [root@localhost mysql] # ll total 200 drwxr-xr-x 2 mysql mysql 4096 Mar 12 00:42 bin -rw-r--r-- 1 mysql mysql 17987 Jul 15 2013 COPYING drwxr-xr-x 3 mysql mysql 4096 Mar 12 00:42 data drwxr-xr-x 2 mysql mysql 4096 Mar 12 00:42 docs drwxr-xr-x 3 mysql mysql 4096 Mar 12 00:42 include -rw-r--r-- 1 mysql mysql 134493 Jul 15 2013 INSTALL-BINARY drwxr-xr-x 3 mysql mysql 4096 Mar 12 00:42 lib drwxr-xr-x 4 mysql mysql 4096 Mar 12 00:42 man drwxr-xr-x 10 mysql mysql 4096 Mar 12 00:42 mysql- test -rw-r--r-- 1 mysql mysql 2496 Jul 15 2013 README drwxr-xr-x 2 mysql mysql 4096 Mar 12 00:42 scripts drwxr-xr-x 27 mysql mysql 4096 Mar 12 00:42 share drwxr-xr-x 4 mysql mysql 4096 Mar 12 00:42 sql-bench drwxr-xr-x 3 mysql mysql 4096 Mar 12 00:42 support-files [root@localhost mysql] # ll /data/mysqldata/ total 16 drwx------ 2 root mysql 16384 Mar 12 00:34 lost+found

Installation and configuration

[root@localhost mysql] # scripts/mysql_install_db --datadir=/data/mysqldata/ --user=mysql

Configure service scripts and mysql configuration files

[root@localhost mysql] # cp support-files/mysql.server /etc/rc.d/init.d/mysqld [root@localhost mysql] # cp support-files/my-large.cnf /etc/my.cnf [root@localhost mysql] # vim /etc/my.cnf

Add service and start mysql

[root@localhost mysql] # chkconfig --add mysqld [root@localhost mysql] # chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@localhost mysql] # service mysqld start Starting MySQL [ OK ] [root@localhost mysql] #

Modify Environment Variables

[root@localhost local ] # vim /etc/profile.d/mysql.sh [root@localhost local ] # . /etc/profile.d/mysql.sh [root@localhost local ] # service mysqld start Starting MySQL [ OK ] [root@localhost local ] # service mysqld stop Shutting down MySQL. [ OK ] [root@localhost local ] # service mysqld start Starting MySQL.. [ OK ] [root@localhost local ] #

Installation is complete. log on to the system for testing.

You can call mysql for the following settings during development:

12345 [root@localhost mysql] # ls bin data include lib mysql- test scripts sql-bench COPYING docs INSTALL-BINARY man README share support-files [root@localhost mysql] # ln -sv /usr/local/mysql/include/ /usr/include/mysql ` /usr/include/mysql ' -> `/usr/local/mysql/include/'

Library file write configuration file

1 [root@localhost mysql] # vim /etc/ld.so.conf.d/mysql.conf

Man document write configuration file

1 vim /etc/man .config

1 [root@localhost mysql] # man mysql

The whole process is over ......

This article is from the "Sea sky" blog, please be sure to keep this source http://il23f.blog.51cto.com/8620950/1381354

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.