天天看點

Mysql學習之--解除安裝源碼mysql-5.6安裝mysql-5.5

系統環境:

作業系統:RedHat EL6

DB Soft:  Mysql 5.5.12

    Mysql 在linux下的安裝方式有兩種版本,一種為Binary(二進制),另外一種為Source(源碼包),本文為Source Install方式。

由于,本機已經安裝了mysql-5.6的版本,前面的版本采用源碼包安裝,隻需要删除相應的安裝檔案即可!

1、解除安裝mysql-5.6

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

删除/var/lib/mysql下的檔案:

[oracle

@ogg

mysql]$ su -

Password:

[root

@ogg

~]# cd /var/lib/mysql/

[root

@ogg

mysql]# ls

auto.cnf     ib_logfile1           mysql-bin.

000001

mysql-bin.

000004

mysql-bin.

000007

ogg.err             test

ibdata1      master-log-bin.index  mysql-bin.

000002

mysql-bin.

000005

mysql-bin.

000008

ogg.pid

ib_logfile0  mysql                 mysql-bin.

000003

mysql-bin.

000006

mysql-bin.index   performance_schema

[root

@ogg

mysql]# rm -rf *

删除/usr/local/mysql下的檔案:

[root

@ogg

mysql]# cd /usr/local/mysql

[root

@ogg

mysql]# ls

bin      data  include         lib  mysql-

5.6

.

4

-m7  README   share      support-files

COPYING  docs  INSTALL-BINARY  man  mysql-test      scripts  sql-bench

[root

@ogg

mysql]# rm -rf mysql-

5.6

.

4

-m7/

[root

@ogg

mysql]# rm -rf *

解除安裝完成!

2、安裝mysql-5.5

1 2 3 4 5 6 7

[[email protected] mysql]# ls

[[email protected] mysql]# cd /home/oracle/mysql

-5.5.

12

[[email protected] mysql

-5.5.

12

]# ls

BUILD        CMakeLists.txt   COPYING  include             libmysqld    mysys      regex      sql-common     tests     win

BUILD-CMAKE  cmd-line-utils   dbug     INSTALL-SOURCE      libservices  packaging  scripts    storage        unittest  zlib

client       config.h.cmake   Docs     INSTALL-WIN-SOURCE  man          plugin     sql        strings        VERSION

cmake        configure.cmake  extra    libmysql            mysql-test   README     sql-bench  support-files  vio

源碼安裝,檢查編譯環境:

[[email protected] mysql-5.5.12]# cmake ./

1 2 3 4 5 6 7 8 9 10 11 12 13 14

-- The C compiler identification is GNU

-- The CXX compiler identification is GNU

-- Check 

for

working C compiler: /usr/bin/gcc

-- Check 

for

working C compiler: /usr/bin/gcc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check 

for

working CXX compiler: /usr/bin/c++

-- Check 

for

working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Looking 

for

SHM_HUGETLB

-- Looking 

for

SHM_HUGETLB - found

-- MySQL 

5.5.

12

……

編譯:

[[email protected] mysql-5.5.12]# make

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Scanning dependencies of target INFO_BIN

[  

%] Built target INFO_BIN

Scanning dependencies of target INFO_SRC

[  

%] Built target INFO_SRC

Scanning dependencies of target abi_check

[  

%] Built target abi_check

[  

%] Generating common.h

[  

%] Generating help.c

[  

%] Generating help.h

[  

%] 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/el.c.o

[  

1

%] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/history.c.o

……

Linking CXX 

static

library libsql.a

[

100

%] Built target sql

Scanning dependencies of target mysqld

[

100

%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o

Linking CXX executable mysqld

[

100

%] Built target mysqld

Scanning dependencies of target udf_example

[

100

%] Building C object sql/CMakeFiles/udf_example.dir/udf_example.c.o

Linking C shared module udf_example.so

[

100

%] Built target udf_example

Scanning dependencies of target my_safe_process

[

100

%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o

Linking CXX executable my_safe_process

[

100

%] Built target my_safe_process

安裝軟體:

[[email protected] mysql-5.5.12]# make install

1 2 3 4 5 6 7 8 9 10 11 12 13

Installing: /usr/local/mysql/mysql-test/./include/have_binlog_format_row.inc

-- Installing: /usr/local/mysql/mysql-test/./include/

assert

.inc

-- Installing: /usr/local/mysql/mysql-test/./include/gis_keys.inc

-- Installing: /usr/local/mysql/mysql-test/./include/implicit_commit_helper.inc

-- Installing: /usr/local/mysql/mysql-test/./include/stop_slave_sql.inc

-- Installing: /usr/local/mysql/mysql-test/./include/have_ucs2.inc

-- Installing: /usr/local/mysql/mysql-test/./include/get_binlog_dump_thread_id.inc

-- Installing: /usr/local/mysql/mysql-test/./include/index_merge_ror_cpk.inc

-- Installing: /usr/local/mysql/mysql-test/./include/linux_sys_vars.inc

-- Installing: /usr/local/mysql/mysql-test/./include/ctype_czech.inc

-- Installing: /usr/local/mysql/mysql-test/./include/have_binlog_format_statement.inc

-- Installing: /usr/local/mysql/mysql-test/./include/mix2.inc

……

3、初始化和配置資料庫

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

[[email protected] mysql]# cd /usr/local/mysql

[[email protected] mysql]# ls

bin  COPYING  data  docs  include  INSTALL-BINARY  lib  man  mysql-test  README  scripts  share  sql-bench  support-files

[[email protected] mysql]# chown -R mysql:mysql .

[[email protected] mysql]# ls -l

total 

76

drwxr-sr-x  

2

mysql mysql  

4096

Sep 

29

15

:

32

bin

-rw-r--r--  

1

mysql mysql 

17987

Apr 

11

2011

COPYING

drwxr-sr-x  

4

mysql mysql  

4096

Sep 

29

15

:

32

data

drwxr-xr-x  

2

mysql mysql  

4096

Sep 

29

15

:

32

docs

drwxr-sr-x  

3

mysql mysql  

4096

Sep 

29

15

:

32

include

-rw-r--r--  

1

mysql mysql  

7370

Apr 

11

2011

INSTALL-BINARY

drwxr-sr-x  

3

mysql mysql  

4096

Sep 

29

15

:

32

lib

drwxr-sr-x  

4

mysql mysql  

4096

Sep 

29

15

:

32

man

drwxr-xr-x 

10

mysql mysql  

4096

Sep 

29

15

:

32

mysql-test

-rw-r--r--  

1

mysql mysql  

2552

Apr 

11

2011

README

drwxr-sr-x  

2

mysql mysql  

4096

Sep 

29

15

:

32

scripts

drwxr-sr-x 

27

mysql mysql  

4096

Sep 

29

15

:

32

share

drwxr-sr-x  

4

mysql mysql  

4096

Sep 

29

15

:

32

sql-bench

drwxr-sr-x  

2

mysql mysql  

4096

Sep 

29

15

:

32

support-files

初始化資料庫:

[[email protected] mysql]# scripts/mysql_install_db --user=mysql

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 ogg 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!

[[email protected] mysql]# chown -R mysql:mysql ./data

[[email protected] mysql]# chmod -R ug+rws .

配置資料庫:

[[email protected] mysql]# vi /etc/my.cnf

[mysqld]

port            = 

3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 

64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

user=mysql

datadir=/

var

/lib/mysql

default-storage-engine=MyISAM

四、啟動并通路資料庫

[[email protected] mysql]# bin/mysqld_safe --user=mysql &

1 2

[[email protected] mysql]# 

140929

15

:

39

:

15

mysqld_safe Logging to 

'/var/lib/mysql/ogg.err'

.

140929

15

:

39

:

15

mysqld_safe Starting mysqld daemon 

with

databases 

from

/

var

/lib/mysql

日志資訊:

[[email protected] mysql]# more /var/lib/mysql/ogg.err

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

140929

15

:

39

:

15

mysqld_safe Starting mysqld daemon 

with

databases 

from

/

var

/lib/mysql

140929

15

:

39

:

15

InnoDB: The InnoDB memory heap is disabled

140929

15

:

39

:

15

InnoDB: Mutexes 

and

rw_locks use GCC atomic builtins

140929

15

:

39

:

15

InnoDB: Compressed tables use zlib 

1.2.

3

140929

15

:

39

:

15

InnoDB: Using Linux native AIO

140929

15

:

39

:

15

InnoDB: Initializing buffer pool, size = 

128.

0M

140929

15

:

39

:

15

InnoDB: Completed initialization of buffer pool

InnoDB: The 

first

specified data file ./ibdata1 did 

not

exist:

InnoDB: a 

new

database to be created!

140929

15

:

39

:

15

InnoDB: Setting file ./ibdata1 size to 

10

MB

InnoDB: Database physically writes the file full: wait...

140929

15

:

39

:

15

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

140929

15

:

39

:

15

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

InnoDB: 

127

rollback segment(s) active.

InnoDB: Creating foreign key constraint system tables

InnoDB: Foreign key constraint system tables created

140929

15

:

39

:

15

InnoDB: Waiting 

for

the background threads to start

140929

15

:

39

:

16

InnoDB: 

1.1.

6

started; log sequence number 

140929

15

:

39

:

16

[Note] Event Scheduler: Loaded 

events

140929

15

:

39

:

16

[Note] /usr/local/mysql/bin/mysqld: ready 

for

connections.

Version: 

'5.5.12-log'

socket: 

'/tmp/mysql.sock'

port: 

3306

Source distribution

[[email protected] mysql]# ls /

var

/lib/mysql

ibdata1      ib_logfile1  mysql-bin

.000001

mysql-bin

.000003

ogg.err  performance_schema

ib_logfile0  mysql        mysql-bin

.000002

mysql-bin.index   ogg.pid  test

檢視server啟動資訊:

[[email protected] mysql]# netstat -an |grep 3306

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN

通路資料庫:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

修改root使用者密碼

[root

@ogg

mysql]# bin/mysqladmin -u root password

New password:

Confirm 

new

password:

連接配接資料庫

[root

@ogg

mysql]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 

3

Server version: 

5.5

.

12

-log Source distribution

Copyright (c) 

2000

2010

, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 

'help;'

or 

'\h'

for

help. Type 

'\c'

to clear the current input statement.

mysql> use mysql;

Database changed

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4

rows in set (

0.00

sec)

mysql>

配置server啟動腳本

[root

@ogg

mysql]# cp support-files/mysql.server  /etc/init.d/mysql

cp: overwrite `/etc/init.d/mysql'? y

[root

@ogg

mysql]# service mysql stop

Shutting down MySQL.

140929

15

:

43

:

39

mysqld_safe mysqld from pid file /var/lib/mysql/ogg.pid ended

[  OK  ]

[

1

]+  Done                    bin/mysqld_safe --user=mysql

[root

@ogg

mysql]# service mysql start

Starting MySQL..                                           [  OK  ]

[root

@ogg

mysql]# netstat -an |grep 

3306

tcp        

0.0

.

0.0

:

3306

0.0

.

0.0

:*                   LISTEN

@至此,mysql安裝成功!

本文轉自 客居天涯 51CTO部落格,原文連結:http://blog.51cto.com/tiany/1559491,如需轉載請自行聯系原作者