Centos6.4平台安裝MySQL

來源:互聯網
上載者:User

標籤:style

平台:centos6.4

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

一,搭建LVM,以及安裝前的準備:

#查看當前磁碟的分區(這裡單獨拿一塊新加磁碟做LVM)

[[email protected] ~]# fdisk -l /dev/sdbDisk /dev/sdb: 128.8 GB, 128849018880 bytes255 heads, 63 sectors/track, 15665 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x946065d9   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        1306    10490413+  83  Linux/dev/sdb2            1307        2612    10490445   83  Linux/dev/sdb3            2613        3918    10490445   83  Linux/dev/sdb4            3919       15665    94357777+   5  Extended/dev/sdb5            3919        7835    31463271   83  Linux/dev/sdb6            7836       11752    31463271   83  Linux

 

#修改磁碟屬性為8e(磁碟8e為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 (command ‘u‘).Command (m for help): tPartition number (1-6): 1Hex code (type L to list codes): 8eChanged system type of partition 1 to 8e (Linux LVM)Command (m for help): tPartition number (1-6): 6Hex code (type L to list codes): 8eChanged system type of partition 6 to 8e (Linux LVM)Command (m for help): tPartition number (1-6): 2Hex code (type L to list codes): 8eChanged system 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, 63 sectors/track, 15665 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 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  Linux LVM/dev/sdb3            2613        3918    10490445   83  Linux/dev/sdb4            3919       15665    94357777+   5  Extended/dev/sdb5            3919        7835    31463271   83  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 [[email 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 -wi-ao---  1.94g                                             [[email protected] ~]# mke2fs -t ext4 -L MYDATA -b 4096 /dev/myvg/mydatamke2fs 1.41.12 (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 filesystem 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 tables: done                            Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 26 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

#開機自動掛載LVM

vim /etc/fstab

添加 : 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="42" />

[[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,gid=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,並修改相關檔案對應屬主屬組

 

[[email protected] ~]# useradd -r mysql[[email protected] ~]# id mysqluid=496(mysql) gid=493(mysql) groups=493(mysql)[[email protected] ~]# cd /mydata[[email protected] mydata]# mkdir data[[email protected] mydata]# chown -R mysql:mysql /mydata/data[[email protected] mydata]# ls -ld /mydata/datadrwxr-xr-x. 2 mysql mysql 4096 Aug  6 20:10 /mydata/data

 

二,安裝MySQL:

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

下載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.tar.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 Aug  6 20:16 bin-rw-r--r--.  1 root mysql  17987 Jul 15  2013 COPYINGdrwxr-xr-x.  3 root mysql   4096 Aug  6 20:17 datadrwxr-xr-x.  2 root mysql   4096 Aug  6 20:16 docsdrwxr-xr-x.  3 root mysql   4096 Aug  6 20:17 include-rw-r--r--.  1 root mysql 134493 Jul 15  2013 INSTALL-BINARYdrwxr-xr-x.  3 root mysql   4096 Aug  6 20:17 libdrwxr-xr-x.  4 root mysql   4096 Aug  6 20:17 mandrwxr-xr-x. 10 root mysql   4096 Aug  6 20:17 mysql-test-rw-r--r--.  1 root mysql   2496 Jul 15  2013 READMEdrwxr-xr-x.  2 root mysql   4096 Aug  6 20:17 scriptsdrwxr-xr-x. 27 root mysql   4096 Aug  6 20:17 sharedrwxr-xr-x.  4 root mysql   4096 Aug  6 20:17 sql-benchdrwxr-xr-x.  3 root mysql   4096 Aug  6 20:17 support-files[[email protected] mysql]# cd support-files/[[email protected] support-files]# ls -ltotal 100-rwxr-xr-x. 1 root mysql  1153 Jul 15  2013 binary-configure-rwxr-xr-x. 1 root mysql  4528 Jul 15  2013 config.huge.ini-rwxr-xr-x. 1 root mysql  2382 Jul 15  2013 config.medium.ini-rwxr-xr-x. 1 root mysql  1626 Jul 15  2013 config.small.ini-rw-r--r--. 1 root mysql   773 Jul 15  2013 magic-rw-r--r--. 1 root mysql  4691 Jul 15  2013 my-huge.cnf-rw-r--r--. 1 root mysql 19759 Jul 15  2013 my-innodb-heavy-4G.cnf-rw-r--r--. 1 root mysql  4665 Jul 15  2013 my-large.cnf-rw-r--r--. 1 root mysql  4676 Jul 15  2013 my-medium.cnf-rw-r--r--. 1 root mysql  2840 Jul 15  2013 my-small.cnf-rwxr-xr-x. 1 root mysql  1061 Jul 15  2013 mysqld_multi.server-rwxr-xr-x. 1 root mysql   839 Jul 15  2013 mysql-log-rotate-rwxr-xr-x. 1 root mysql 10880 Jul 15  2013 mysql.server-rwxr-xr-x. 1 root mysql  1326 Jul 15  2013 ndb-config-2-node.inidrwxr-xr-x. 2 root mysql  4096 Aug  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

 

添加語句: 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="42" />

#添加服務指令碼,開機自動運行

[[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 be looked up with resolveip.This probably means that your libc libraries are not 100 % compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges !Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:./bin/mysqladmin -u root password ‘new-password‘./bin/mysqladmin -u root -h magine356wj password ‘new-password‘Alternatively you can run:./bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  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 any problems with the ./bin/mysqlbug script!

 

#啟動mysqld,並檢查是否監聽3306連接埠

[[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      128                                   :::111                                  :::*     LISTEN     0      128                                    *:111                                   *:*     LISTEN     0      128                                   :::22                                   :::*     LISTEN     0      128                                    *:22                                    *:*     LISTEN     0      128                                   :::40054                                :::*     LISTEN     0      128                                    *:38550                                 *:*     LISTEN     0      128                            127.0.0.1:631                                   *:*     LISTEN     0      128                                  ::1:631                                  :::*     LISTEN     0      100                                  ::1:25                                   :::*     LISTEN     0      100                            127.0.0.1:25                                    *:*     LISTEN     0      128                            127.0.0.1:6010                                  *:*     LISTEN     0      128                                  ::1:6010                                 :::*     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    profile.d/ [[email protected] ~]# vim /etc/profile.d/mysql.sh##########################################################################添加語句:export PATH = /usr/local/mysql/bin:$PATH[[email protected] ~]# . /etc/profile.d/mysql.sh 

#添加庫檔案

 

[[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

三,安裝完成,測試:

[[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) 2000, 2013, 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.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
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.