MySQL-5.5.28コンパイルインストール

8970 ワード

    MySQL-5.5

cmake              (out-of-source)     ,
                          ,                    ,
                     ,          。

    MySQL-5.5

 、      
[root@CentOS6 ~]#  yum install "Compatibility libraries" "Development tools" "gcc-c++"

 、    cmake

[root@CentOS6 ~]#  https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz
[root@CentOS6 ~]#  tar xf cmake-3.4.1.tar.gz
[root@CentOS6 ~]#  cd cmake-3.4.1
[root@CentOS6 cmake-3.4.1]#  ./bootstrap
[root@CentOS6 cmake-3.4.1]#  make 
[root@CentOS6 cmake-3.4.1]#  make install


 、  MySQL      
[root@CentOS6 ~]# fdisk /dev/sda 

WARNING: 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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7dd89809

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1306    10490413+  8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@CentOS6 ~]# cat /proc/partitions 
major minor  #blocks  name

   8        0   20971520 sda
   8        1   10490413 sda1
   8       16   20971520 sdb
   8       17     512000 sdb1
   8       18   20458496 sdb2
 253        0   18423808 dm-0
 253        1    2031616 dm-1
[root@CentOS6 ~]# pvcreate /dev/sda1 
  Physical volume "/dev/sda1" successfully created
[root@CentOS6 ~]# vgcreate myvg /dev/sda1
  Volume group "myvg" successfully created
[root@CentOS6 ~]# lvcreate -L 5G -n mylv myvg
  Logical volume "mylv" created
[root@CentOS6 ~]# mke2fs -j /dev/mapper/myvg-mylv 
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@CentOS6 ~]# mkdir /mydata
[root@CentOS6 ~]# vim /etc/fstab 		
[root@CentOS6 ~]# tail -1 /etc/fstab						#          
/dev/mapper/myvg-mylv	/mydata		ext3	defaults	0 0
[root@CentOS6 ~]# mount -a
[root@CentOS6 ~]# mkdir /mydata/data
[root@CentOS6 ~]# ls /mydata
data  lost+found
[root@CentOS6 ~]# chown -R  mysql.mysql /mydata/data
[root@CentOS6 ~]# ll /mydata/data -d
drwxr-xr-x 2 mysql mysql 4096 Dec 19 20:34 /mydata/data



 、  mysql  
[root@CentOS6 ~]#  groupadd -r mysql
[root@CentOS6 ~]#  useradd -g mysql -r -d /mydata/data mysql

 、       mysql-5.5.28
[root@CentOS6 tmp]#  wget https://downloads.mariadb.com/archives/mysql-5.5/mysql-5.5.28.tar.gz
[root@CentOS6 tmp]#  tar xf mysql-5.5.28.tar.gz 
[root@CentOS6 tmp]#  cd mysql-5.5.28
[root@CentOS6 tmp]#  cmake . -LH						#       
[root@CentOS6 mysql-5.5.28]#  cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
          -DMYSQL_DATADIR=/mydata/data \
          -DSYSCONFDIR=/etc \
		  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
          -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
          -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
		  -DWITH_READLINE=1 \
		  -DWITH_SSL=system \
		  -DWITH_ZLIB=system \
		  -DWITH_LIBWRAP=0 \
		  -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
		  -DDEFAULT_CHARSET=utf8 \
          -DDEFAULT_COLLATION=utf8_general_ci
 Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
[root@CentOS6 mysql-5.5.28]#  yum install -y ncurses-devel
[root@CentOS6 mysql-5.5.28]#  rm -f CMakeCache.txt
[root@CentOS6 mysql-5.5.28]#  make 
[root@CentOS6 mysql-5.5.28]#  make install


 、MySQL      
[root@CentOS6 mysql-5.5.28]# cd /usr/local/mysql
[root@CentOS6 mysql]# pwd
/usr/local/mysql
[root@CentOS6 mysql]# chown -R .mysql .
[root@CentOS6 mysql]# ll
total 76
drwxr-xr-x  2 root mysql  4096 Dec 19 21:09 bin
-rw-r--r--  1 root mysql 17987 Aug 29  2012 COPYING
drwxr-xr-x  4 root mysql  4096 Dec 17 16:03 data
drwxr-xr-x  2 root mysql  4096 Dec 19 21:09 docs
drwxr-xr-x  3 root mysql  4096 Dec 19 21:09 include
-rw-r--r--  1 root mysql  7604 Aug 29  2012 INSTALL-BINARY
drwxr-xr-x  3 root mysql  4096 Dec 19 21:09 lib
drwxr-xr-x  4 root mysql  4096 Dec 12 10:39 man
drwxr-xr-x 10 root mysql  4096 Dec 19 21:09 mysql-test
-rw-r--r--  1 root mysql  2552 Aug 29  2012 README
drwxr-xr-x  2 root mysql  4096 Dec 19 21:09 scripts
drwxr-xr-x 27 root mysql  4096 Dec 17 13:50 share
drwxr-xr-x  4 root mysql  4096 Dec 19 21:09 sql-bench
drwxr-xr-x  2 root mysql  4096 Dec 19 21:09 support-files

[root@CentOS6 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE 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 CentOS6.5 password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly 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.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!
       
[root@CentOS6 mysql]# cp support-files/my-large.cnf /etc/my.cnf
[root@CentOS6 mysql]# vim /etc/my.cnf
[root@CentOS6 mysql]# grep -C 1 "datadir" /etc/my.cnf 	#      ,        
thread_concurrency = 8
datadir = /mydata/data
innodb_file_per_table = 1
[root@CentOS6 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@CentOS6 mysql]# chkconfig --add mysqld
[root@CentOS6 mysql]# chkconfig --list mysqld
mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off

 、  MySQL PATH        
[root@CentOS6 mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysqld.sh
[root@CentOS6 mysql]# . /etc/profile.d/mysqld.sh
[root@CentOS6 mysql]# ln -sv /usr/local/mysql/include  /usr/include/mysql

 、      MySQL,      、  root         
[root@CentOS6 mysql]# service mysqld start
Starting MySQL... SUCCESS! 

(1)、      
[root@CentOS6 mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.28-log Source distribution

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

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> SELECT User,Host,Password FROM mysql.user;
+------+-----------+----------+
| User | Host      | Password |
+------+-----------+----------+
| root | localhost |          |
| root | CentOS6.5 |          |
| root | 127.0.0.1 |          |
| root | ::1       |          |
|      | localhost |          |
|      | CentOS6.5 |          |
+------+-----------+----------+
5 rows in set (0.00 sec)

mysql> DELETE FROM mysql.user WHERE User='';
Query OK, 2 rows affected (0.00 sec)

mysql> exit
Bye

(2)、  root    
mysql> UPDATE mysql.user SET Password=PASSWORD('redhat') WHERE User='root';
Query OK, 4 rows affected (0.06 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

(3)、      
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

転載先:https://blog.51cto.com/soysauce93/1726868