Centos6.4 platform Installation MySQL

Source: Internet
Author: User

Platform: centos6.4

Mysql:mysql-5.5.33-linux2.6-x86_64.tar.gz

One, build LVM, and prepare before installation:

#查看当前磁盘的分区 (here alone with a new plus disk for LVM)

[Email protected] ~]# fdisk-l/dev/sdbdisk/dev/sdb:128.8 GB, 128849018880 bytes255 heads, + sectors/track, 15665 Cyli Ndersunits = Cylinders of 16065 * 8225280 bytessector size (logical/physical): bytes/512 bytesi/o Size (minimu M/optimal): bytes/512 bytesdisk identifier:0x946065d9   Device Boot      Start         End      Blocks   Id  SYSTEM/DEV/SDB1               1        1306    10490413+  linux/dev/sdb2            1307        2612    10490445   the  LINUX/DEV/SDB3            2613        3918    10490445   ,  linux/dev/sdb4            3919       15665    94357777+   5  extended/dev/sdb5            3919        7835  31463271            -LINUX/DEV/SDB6 7836       11752    31463271  Linux

#修改磁盘属性为8e (disk 8e is LVM)

[[email protected] ~]# fdisk/dev/sdbwarning:dos-compatible mode is deprecated. It ' s strongly recommended to switch off the mode (command ' C ') and change display units to sectors (Comman d ' u '). Command (M for help): Tpartition number (1-6): 1Hex code (type L to list codes): 8eChanged system type of partition 1 to 8 E (Linux LVM) Command (M for help): Tpartition number (1-6): 6Hex code (type L to list codes): 8eChanged system type of par Tition 6 to 8e (Linux LVM) Command (M-help): Tpartition number (1-6): 2Hex code (type L to list codes): 8eChanged syste M type of partition 2 to 8e (Linux LVM) Command ("M for Help"): W the partition table has been altered! Calling IOCTL () to re-read partition table. Syncing disks.  [[email protected] ~]# fdisk-l/dev/sdbdisk/dev/sdb:128.8 GB, 128849018880 bytes255 heads, Sectors/track, 15665 Cylindersunits = Cylinders of 16065 * 8225280 bytessector size (logical/physical): bytes/512 bytesi/o size (m Inimum/optimal): bytes/512 bytesdisk identifier:0x946065d9 Device Boot Start End Blocks Id system/ DEV/SDB1 1 1306 10490413+ 8e Linux lvm/dev/sdb2 1307 2612 10490445 8e Li   Nux lvm/dev/sdb3 2613 3918 10490445 3919 linux/dev/sdb4 15665 94357777+ 5   EXTENDED/DEV/SDB5 3919 7835 31463271 linux/dev/sdb6 7836 11752 31463271 8e Linux LVM

#创建LVM

[[email protected] ~]# pvcreate/dev/sdb{1,2,6} physical Volume "/DEV/SDB1" Successfully created physical volume "/  DEV/SDB2 "Successfully created physical volume"/DEV/SDB6 "successfully created[[email protected] ~]# vgcreate MYVG    /dev/sdb{1,2,6} Volume Group "MYVG" successfully created[[email protected] ~]# vgs VG #PV #LV #SN Attr Vsize vfree MYVG 3 0 0 wz--n-50.00g 50.00g vg_magine356wj 1 3 0 wz--n-119.51g 0 [[EMA]      Il protected] ~]# lvcreate-l 20g-n mydata myvg Logical Volume "MyData" created[[email protected] ~]# LVs LV                                                VG Attr lsize Pool Origin data% Move Log cpy%sync Convert mydata myvg-wi-a----20.00g                                               Lv_home Vg_magine356wj-wi-ao---67.57g Lv_root Vg_magine356wj-wi-ao---50.00g lv_swap vg_magine356wj-w           I-ao---1.94g                                  [[email protected] ~]# mke2fs-t ext4-l mydata-b 4096/dev/myvg/mydatamke2fs 1.41 . (17-may-2010) Filesystem Label=mydataos type:linuxblock size=4096 (log=2) Fragment size=4096 (log=2) stride=0 blocks, Stripe blocks1310720 inodes, 5242880 blocks262144 blocks (5.00%) reserved for the Super Userfirst data block=0maximum fil Esystem blocks=4294967296160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupsuperblock Backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000Writing inode tab Les:done Creating Journal (32768 blocks): donewriting superblocks and filesystem accounting in  Formation:donethis filesystem would be automatically checked every-mounts or180 days, whichever comes first. Use Tune2fs-c or-i to override.

#开机自动挂载LVM

Vim/etc/fstab

Added: 650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201408/6/2664956_ 1407307193o75f.png "" 562 "height="/>

[[email protected] ~]# mkdir/mydata[[email protected] ~]# mount-a[[email protected] ~]# MOUNT/DEV/MAPPER/VG_MAGINE356WJ -lv_root on/type ext4 (rw) proc On/proc type proc (rw) Sysfs On/sys type SYSFS (rw) devpts on/dev/pts type devpts (rw,gi d=5,mode=620) Tmpfs on/dev/shm type Tmpfs (rw,rootcontext= "System_u:object_r:tmpfs_t:s0")/dev/sda1 on/boot type EXT4 ( RW)/dev/mapper/vg_magine356wj-lv_home on/home type EXT4 (rw) None On/proc/sys/fs/binfmt_misc type Binfmt_misc (rw) Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)/dev/mapper/myvg-mydata on/mydata type EXT4 (rw)

#新建用户mysql, and modify the relevant file corresponding to the main genus Group

[[email protected] ~]# useradd-r mysql[[email protected] ~]# ID mysqluid=496 (mysql) gid=493 (MySQL) groups=493 (MySQL) [[em AIL protected] ~]# cd/mydata[[email protected] mydata]# mkdir data[[email protected] mydata]# chown-r Mysql:mysql/mydat A/data[[email protected] mydata]# ls-ld/mydata/datadrwxr-xr-x. 2 MySQL mysql 4096  6 20:10/mydata/data

Two, install MySQL:

http://dev.mysql.com/downloads/mysql/

Download mysql-5.5.33-linux2.6-x86_64.tar.gz

[[email protected] ~]# lsanaconda-ks.cfg install.log.syslog linux-3.10.tar.xzinstall.log linux-2.6.32.60.t AR.XZ mysql-5.5.33-linux2.6-x86_64.tar.gz[[email protected] ~]# tar XF mysql-5.5.33-linux2.6-x86_64.tar.gz-c/ Usr/local[[email protected] ~]# cd/usr/local[[email protected] local]# ln-sv mysql-5.5.33-linux2.6-x86_64 /MySQL ' MySQL ', ' mysql-5.5.33-linux2.6-x86_64/' [[email protected] local]# CD mysql/[[email protected] mysql]# chown-r root:mysql/usr/local/mysql/*[[email protected] mysql]# ls-l/usr/local/mysql/total  200drwxr-xr-x. 2 root MySQL 4096 6 20:16 bin-rw-r--r--.  1 root MySQL 17987 Jul copyingdrwxr-xr-x.  3 root MySQL 4096 6 20:17 datadrwxr-xr-x.  2 root MySQL 4096 6 20:16 docsdrwxr-xr-x.  3 root MySQL 4096 6 20:17 include-rw-r--r--.  1 root MySQL 134493 Jul install-binarydrwxr-xr-x.  3 root MySQL 4096 6 20:17 libdrwxr-xr-x. 4 root MySQL 4096 6 20:17 mandrwxR-xr-x.  Root MySQL 4096 6 20:17 mysql-test-rw-r--r--.  1 root MySQL 2496 Jul readmedrwxr-xr-x. 2 root MySQL 4096 6 20:17 scriptsdrwxr-xr-x.  Root MySQL 4096 6 20:17 sharedrwxr-xr-x.  4 root MySQL 4096 6 20:17 sql-benchdrwxr-xr-x. 3 root MySQL 4096 6 20:17 support-files[[email protected] mysql]# CD support-files/[[email protected] Sup port-files]# ls-ltotal 100-rwxr-xr-x. 1 root MySQL 1153 Jul binary-configure-rwxr-xr-x. 1 root MySQL 4528 Jul config.huge.ini-rwxr-xr-x. 1 root MySQL 2382 Jul config.medium.ini-rwxr-xr-x. 1 root MySQL 1626 Jul config.small.ini-rw-r--r--. 1 root MySQL 773 Jul magic-rw-r--r--. 1 root mysql 4691 Jul my-huge.cnf-rw-r--r--. 1 root mysql 19759 Jul my-innodb-heavy-4g.cnf-rw-r--r--. 1 root mysql 4665 Jul my-large.cnf-rw-r--r--. 1 root mysql 4676 Jul my-medium.cnf-rw-r--r--. 1 root MySQL 2840 Jul my-small. Cnf-rwxr-xr-x. 1 root MySQL 1061 Jul mysqld_multi.server-rwxr-xr-x. 1 root MySQL 839 Jul mysql-log-rotate-rwxr-xr-x. 1 root MySQL 10880 Jul mysql.server-rwxr-xr-x. 1 root MySQL 1326 Jul ndb-config-2-node.inidrwxr-xr-x. 2 root MySQL 4096 6 20:17 solaris[[email protected] support-files]# cp my-large.cnf/etc/my.cnfcp:overwrite '/ Etc/my.cnf '? y [[email protected] support-files]# vim/etc/my.cnf

Add statement: DataDir =/mydata/data

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; margin:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201408/6/2664956_ 1407307193ohfo.png "" 198 "height="/>

#添加服务脚本, Start automatically

[[email protected] support-files]# CP mysql.server/etc/rc.d/init.d/mysqld[[email protected] support-files]# chkconfig --add Mysqld[[email protected] support-files]# chkconfig--list mysqldmysqld         0:off1:off2:on3:on4:on5:on6:off

#MySQL初始化

[[email protected] support-files]# CD. [[email protected] mysql]# ls scripts/mysql_install_db[[email protected] mysql]# scripts/mysql_install_db --user=mysql--datadir=/mydata/datawarning:the host ' MAGINE356WJ ' could not being looked up with RESOLVEIP. This probably means that your libc libraries is not the Compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving won't work. This means the should use IP addresses instead of Hostnameswhen specifying MySQL privileges! Installing MySQL system tables ... Okfilling Help Tables ... OKto start mysqld at boot time has to copysupport-files/mysql.server to the right place for your systemplease Remembe R to SET A PASSWORD for the MySQL root USER! To does, start the server, then issue the following commands:./bin/mysqladmin-u root password ' new-password './bin/mysqla Dmin-u root-h magine356wj password ' new-password ' Alternatively you can run:./bin/mYsql_secure_installationwhich would also give you the option of removing the testdatabases and anonymous user created by de  Fault. This isstrongly recommended for production servers. See the Manual for more instructions. You can start the MySQL daemon with:cd. ;./bin/mysqld_safe &you can test the MySQL daemon with MYSQL-TEST-RUN.PLCD./mysql-test; Perl mysql-test-run.plplease Report no problems with the./bin/mysqlbug script!

#启动mysqld, and check if 3306 ports are listening

[[email protected] mysql]# service mysqld startstarting MySQL ... [OK]                       [[email protected] mysql]# ss-tanlstate recv-q send-q Local address:port      Peer address:port LISTEN 0::: 111:::*       LISTEN 0 *:111 *:* LISTEN 0                                    +::: +:::* LISTEN 0 128                                   *:22 *:* LISTEN 0 128 ::: 40054:::* LISTEN 0 128 *:3855                                   0 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0:: 1:631:::* LISTEN 0 1                            XX:: 1:25:::* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.                                 0.0.1:6010 *:* LISTEN 0 128:: 1:6,010                                  :::* LISTEN 0 50 *:3306    *:*

#设置环境变量

#设置man

[Email protected] ~]# vim/etc/man.config######################################################################## # #48行后添加语句: Manpath/usr/local/mysql/man

#添加头文件

[Email protected] ~]# ln-sv/usr/local/mysql/include/usr/include/mysql '/usr/include/mysql '/usr/local/mysql/ Include ' [[email protected] ~]# ls/usr/include/mysql/decimal.h   my_attribute.h  my_global.h   mysqld_ Ername.h  my_sys.h           sql_state.herrmsg.h    my_compiler.h   my_list.h     mysqld_error.h   my_xml.h           sslopt-case.hkeycache.h  my_config.h     my_net.h      mysql_embed.h    plugin_audit.h     Sslopt-longopts.hm_ctype.h   my_dbug.h       my_pthread.h  mysql.h          plugin_ftparser.h  Sslopt-vars.hm_string.h  my_dir.h        mysql         mysql_time.h     plugin.h           typelib.hmy_alloc.h  my_getopt.h     mysql_com.h   mysql_version.h  sql_common.h

[Email protected] mysql]# cd[[email protected] ~]# vim/etc/profileprofile    

#添加库文件

[Email protected] ~]# vim/etc/ld.so.confld.so.conf    ld.so.conf.d/[[email protected] ~]# vim/etc/ld.so.conf.d/ mysql.conf######################################################################### #添加语句:/usr/local/mysql/lib[ [Email protected] ~]# Ldconfig-v | grep mysql/usr/local/mysql/lib:libmysqlclient.so.18-Libmysqlclient_r.so.18.0.0/usr/lib64/mysql: libmysqlclient.so.16, libmysqlclient.so.16.0.0libmysqlclient_r.so.16, libmysqlclient_r.so.16.0.0

Three, installation complete, test:

[Email protected] ~]# Mysqlwelcome to the MySQL Monitor.  Commands End With;  or \g.your MySQL connection ID is 2Server version:5.5.33-log mysql Community Server (GPL) Copyright (c) +, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> SELECT VERSION (); +------------+| VERSION ()  |+------------+| 5.5.33-log |+------------+1 row in Set (0.00 sec) mysql> SHOW databases;+------------- -------+| Database           |+--------------------+| information_schema | | mysql              | | performance_schema | | Test               |+---------- ----------+4 rows in Set (0.01 sec) mysql> \qbye

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.