MYSQL Study案例之--通过源码安装Mysql-5.6

MYSQL  Study案例之--通过源码安装Mysql-5.6

系统环境

操作系统:RedHat EL6

DB Soft:  Mysql 5.6.4-m7

1、系统环境

[root@rh6 Packages]# uname -a
Linux rh6 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@rh6 Packages]#

2、安装cmake软件

[root@rh6 Packages]# rpm -ivh cmake-2.6.4-5.el6.x86_64.rpm
warning: cmake-2.6.4-5.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:cmake                  ########################################### [100%]

3、源码安装mysql

[root@rh6 Packages]# cd /home/oracle/mysql-5.6.4-m7

[root@rh6 mysql-5.6.4-m7]# ls

BUILD           config.h.cmake       extra               libservices  README      storage        vio

BUILD-CMAKE     configure.cmake      include             man          regex       strings        win

client          COPYING              INSTALL-SOURCE      mysql-test   scripts     support-files  zlib

cmake           dbug                 INSTALL-WIN-SOURCE  mysys        sql         tests

CMakeLists.txt  Docs                 libmysql            packaging    sql-bench   unittest

cmd-line-utils  Doxyfile-perfschema  libmysqld           plugin       sql-common  VERSION


查看编译环境:

[root@rh6 mysql-5.6.4-m7]# cmake ./
-- Check size of wchar_t - done
-- Check size of wctype_t
-- Check size of wctype_t - done
-- Check size of wint_t
-- Check size of wint_t - done
-- Found Curses: /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Performing Test HAVE_DECL_TGOTO
-- Performing Test HAVE_DECL_TGOTO - Success
-- Looking for strvis
-- Looking for strvis - not found
-- Looking for strunvis
-- Looking for strunvis - not found
-- Looking for include files HAVE_LIBAIO_H
-- Looking for include files HAVE_LIBAIO_H - found
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - found
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
-- Configuring done
-- Generating done
-- Build files have been written to: /home/oracle/mysql-5.6.4-m7

编译:

[root@rh6 mysql-5.6.4-m7]# make
Scanning dependencies of target INFO_BIN
[  0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[  0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[  0%] Built target abi_check
[  1%] Generating common.h
[  1%] Generating help.c
[  1%] Generating help.h
[  1%] Generating vi.h
[  1%] Generating emacs.h
[  1%] Generating fcns.c
[  1%] Generating fcns.h
Scanning dependencies of target edit
[  1%] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/chared.c.o
[  1%] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/chartype.c.o
[  1%] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/el.c.o

安装:

[root@rh6 mysql-5.6.4-m7]# make install
[  0%] Built target INFO_BIN
[  0%] Built target INFO_SRC
[  0%] Built target abi_check
[  5%] Built target edit
[  6%] Built target mysqlservices
[ 12%] Built target strings
[ 25%] Built target mysys
[ 25%] Built target dbug
[ 25%] Built target comp_err
[ 25%] Built target GenError
[ 25%] Built target blackhole
[ 25%] Built target example
[ 25%] Built target archive
[ 34%] Built target perfschema
[ 35%] Built target mytap
[ 35%] Built target pfs-t
[ 35%] Built target pfs_account-oom-t
[ 35%] Built target pfs_host-oom-t
[ 36%] Built target pfs_instr-oom-t
[ 36%] Built target pfs_instr-t
[ 36%] Built target pfs_instr_class-oom-t
[ 36%] Built target pfs_instr_class-t
[ 36%] Built target pfs_user-oom-t

4、数据库初始化

[root@rh6 mysql-5.6.4-m7]# cd /usr/local/mysql
[root@rh6 mysql]# ls
bin      data  include         lib  mysql-test  scripts  sql-bench
COPYING  docs  INSTALL-BINARY  man  README      share    support-files
[root@rh6 mysql]# ls -l
total 76
drwxr-xr-x  2 root root  4096 Jan 28 17:16 bin
-rw-r--r--  1 root root 17987 Dec 14  2011 COPYING
drwxr-xr-x  4 root root  4096 Jan 28 17:16 data
drwxr-xr-x  2 root root  4096 Jan 28 17:16 docs
drwxr-xr-x  3 root root  4096 Jan 28 17:16 include
-rw-r--r--  1 root root  7369 Dec 14  2011 INSTALL-BINARY
drwxr-xr-x  3 root root  4096 Jan 28 17:16 lib
drwxr-xr-x  4 root root  4096 Jan 28 17:16 man
drwxr-xr-x 10 root root  4096 Jan 28 17:16 mysql-test
-rw-r--r--  1 root root  2552 Dec 14  2011 README
drwxr-xr-x  2 root root  4096 Jan 28 17:16 scripts
drwxr-xr-x 27 root root  4096 Jan 28 17:16 share
drwxr-xr-x  4 root root  4096 Jan 28 17:16 sql-bench
drwxr-xr-x  2 root root  4096 Jan 28 17:16 support-files
[root@rh6 mysql]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
[root@rh6 mysql]# chown -R mysql:mysql .
[root@rh6 mysql]# ls -l
total 76
drwxr-xr-x  2 mysql mysql  4096 Jan 28 17:16 bin
-rw-r--r--  1 mysql mysql 17987 Dec 14  2011 COPYING
drwxr-xr-x  4 mysql mysql  4096 Jan 28 17:16 data
drwxr-xr-x  2 mysql mysql  4096 Jan 28 17:16 docs
drwxr-xr-x  3 mysql mysql  4096 Jan 28 17:16 include
-rw-r--r--  1 mysql mysql  7369 Dec 14  2011 INSTALL-BINARY
drwxr-xr-x  3 mysql mysql  4096 Jan 28 17:16 lib
drwxr-xr-x  4 mysql mysql  4096 Jan 28 17:16 man
drwxr-xr-x 10 mysql mysql  4096 Jan 28 17:16 mysql-test
-rw-r--r--  1 mysql mysql  2552 Dec 14  2011 README
drwxr-xr-x  2 mysql mysql  4096 Jan 28 17:16 scripts
drwxr-xr-x 27 mysql mysql  4096 Jan 28 17:16 share
drwxr-xr-x  4 mysql mysql  4096 Jan 28 17:16 sql-bench
drwxr-xr-x  2 mysql mysql  4096 Jan 28 17:16 support-files
[root@rh6 mysql]# 
[root@rh6 mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
150128 17:21:30 InnoDB: The InnoDB memory heap is disabled
150128 17:21:30 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150128 17:21:30 InnoDB: Compressed tables use zlib 1.2.3
150128 17:21:30 InnoDB: Using Linux native AIO
150128 17:21:30 InnoDB: CPU does not support crc32 instructions
150128 17:21:30 InnoDB: Initializing buffer pool, size = 128.0M
150128 17:21:30 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
150128 17:21:30 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
150128 17:21:31 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
150128 17:21:31 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
150128 17:21:31 InnoDB: 128 rollback segment(s) are active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
150128 17:21:31 InnoDB: Waiting for the background threads to start
......
150128 17:21:38 [Note] Shutting down plugin 'mysql_native_password'
150128 17:21:38 [Note] Shutting down plugin 'binlog'
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 rh6 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@rh6 mysql]# chown -R mysql:mysql ./data
[root@rh6 mysql]# chmod -R ug+rws .
[root@rh6 mysql]# ls -l
total 76
drwsrwsr-x  2 mysql mysql  4096 Jan 28 17:16 bin
-rwSrwSr--  1 mysql mysql 17987 Dec 14  2011 COPYING
drwsrwsr-x  4 mysql mysql  4096 Jan 28 17:16 data
drwsrwsr-x  2 mysql mysql  4096 Jan 28 17:16 docs
drwsrwsr-x  3 mysql mysql  4096 Jan 28 17:16 include
-rwSrwSr--  1 mysql mysql  7369 Dec 14  2011 INSTALL-BINARY
drwsrwsr-x  3 mysql mysql  4096 Jan 28 17:16 lib
drwsrwsr-x  4 mysql mysql  4096 Jan 28 17:16 man
drwsrwsr-x 10 mysql mysql  4096 Jan 28 17:16 mysql-test
-rwSrwSr--  1 mysql mysql  2552 Dec 14  2011 README
drwsrwsr-x  2 mysql mysql  4096 Jan 28 17:16 scripts
drwsrwsr-x 27 mysql mysql  4096 Jan 28 17:16 share
drwsrwsr-x  4 mysql mysql  4096 Jan 28 17:16 sql-bench
drwsrwsr-x  2 mysql mysql  4096 Jan 28 17:16 support-files

5、查看mysql配置文件

[root@rh6 mysql]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

6、启动mysqld服务

[root@rh6 mysql]# bin/mysqld_safe --user=mysql &
[1] 13138

[root@rh6 mysql]# 150128 17:25:19 mysqld_safe Logging to '/var/log/mysqld.log'.
150128 17:25:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@rh6 mysql]# ps -ef |grep mysql
root     13138  2175  1 17:25 pts/0    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql    13276 13138  3 17:25 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

[root@rh6 mysql]# netstat -an |grep :3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN 

查看系统日志:
[root@rh6 log]# more /var/log/mysqld.log 
150128 17:25:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150128 17:25:19 InnoDB: The InnoDB memory heap is disabled
150128 17:25:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150128 17:25:19 InnoDB: Compressed tables use zlib 1.2.3
150128 17:25:19 InnoDB: Using Linux native AIO
150128 17:25:19 InnoDB: CPU does not support crc32 instructions
150128 17:25:19 InnoDB: Initializing buffer pool, size = 128.0M
150128 17:25:19 InnoDB: Completed initialization of buffer pool
150128 17:25:19 InnoDB: highest supported file format is Barracuda.
150128 17:25:20 InnoDB: 128 rollback segment(s) are active.
150128 17:25:20 InnoDB: Waiting for the background threads to start
150128 17:25:21 InnoDB: 1.2.4 started; log sequence number 1602851
150128 17:25:21 [Warning] No existing UUID has been found, so we assume that this is the first time that this serv
er has been started. Generating a new UUID: 94adecc3-a6cf-11e4-87f0-080027ac3540.
150128 17:25:21 [Note] Event Scheduler: Loaded 0 events
150128 17:25:21 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.6.4-m7'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
[root@rh6 log]#

7、修改root(mysql)用户口令

[root@rh6 mysql]# mysqladmin version
mysqladmin  Ver 8.42 Distrib 5.1.66, for redhat-linux-gnu on x86_64
Copyright (c) 2000, 2012, 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.
Server version          5.6.4-m7
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 11 min 16 sec
Threads: 1  Questions: 1  Slow queries: 0  Opens: 66  Flush tables: 1  Open tables: 59  Queries per second avg: 0.001
[root@rh6 mysql]# 
[root@rh6 mysql]# mysqladmin -u root -p password "oracle"
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
[root@rh6 mysql]# mysqladmin -u root -p password "oracle"
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
[root@rh6 mysql]# mysqladmin -u root -p password "oracle"
Enter password:

8、连接mysql server

[root@rh6 mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.4-m7 Source distribution
Copyright (c) 2000, 2012, 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> 

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)

mysql> use test;
Database changed

mysql> show tables;
Empty set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
29 rows in set (0.00 sec)
mysql>

9 查看mysql引擎

mysql> show engines;
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                    | Transactions | XA   | Savepoints |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| MyISAM             | YES     | MyISAM storage engine                                      | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                         | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                         | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.01 sec)

[root@rh6 bin]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.4-m7 Source distribution

Copyright (c) 2000, 2012, 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> show engines \G
*************************** 1. row ***************************
      Engine: MyISAM
     Support: YES
     Comment: MyISAM storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 2. row ***************************
      Engine: InnoDB
     Support: DEFAULT
     Comment: Supports transactions, row-level locking, and foreign keys
Transactions: YES
          XA: YES
  Savepoints: YES
*************************** 3. row ***************************
      Engine: MRG_MYISAM
     Support: YES
     Comment: Collection of identical MyISAM tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 4. row ***************************
      Engine: PERFORMANCE_SCHEMA
     Support: YES
     Comment: Performance Schema
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 5. row ***************************
      Engine: CSV
     Support: YES
     Comment: CSV storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 6. row ***************************
      Engine: MEMORY
     Support: YES
     Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
          XA: NO
  Savepoints: NO
6 rows in set (0.01 sec)

默认引擎是:InnoDB


@至此,mysql安装已经完成!

本文出自 “天涯客的blog” 博客,请务必保留此出处http://tiany.blog.51cto.com/513694/1609310

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值