天天看點

linux 下 MySQL源碼包的安裝

linux 下 MySQL源碼包的安裝

實驗環境 VMware 6.5.2 +redhatEnterprise 5 AS

實驗目的 初步涉及源碼包的安裝,以簡單實作其功能為目的,不對原理進行深層讨論

核心版本:

<a href="http://yuzeying.blog.51cto.com/attachment/200905/1/644976_1241165675Gb87.jpg"></a>

今天嘗試安裝MySQL的源碼包 mysql-4.0.27.tar.gz

下載下傳源碼包 copy 到linux

[root@localhost ~]# cd /tmp

[root@localhost tmp]# ls

gconfd-laowu scim-helper-manager-socket-root

gconfd-root scim-panel-socket:0-laowu

keyring-8zb2FJ scim-panel-socket:0-root

linuxqq_v1.0.2-beta1_i386 scim-socket-frontend-root

linuxqq_v1.0.2-beta1_i386.tar.gz sealert.log

mapping-laowu ssh-lgCAZY2854

mapping-root virtual-root.Kez8K1

mysql-4.0.27.tar.gz VMwareDnD

orbit-root vmware-root

scim-bridge-0.3.0.lockfile-0@localhost:0.0 VMwareTools-7.8.4-126130.tar.gz

scim-bridge-0.3.0.socket-0@localhost:0.0 vmware-tools-distrib

[root@localhost tmp]#

[root@localhost tmp]# tar zxvf mysql-4.0.27.tar.gz

把源碼包mysql-4.0.27.tar.gz 解壓到目前目錄

<a href="http://yuzeying.blog.51cto.com/attachment/200905/1/644976_1241165677Ky73.jpg"></a>

[root@localhost tmp]# cd mysql-4.0.27

進入mysql-4.0.27目錄

[root@localhost mysql-4.0.27]# ls

acconfig.h configure.in INSTALL-SOURCE missing regex

acinclude.m4 COPYING isam mkinstalldirs scripts

aclocal.m4 dbug libmysql myisam sql

bdb depcomp libmysqld myisammrg sql-bench

BUILD Docs libmysql_r mysql-test strings

ChangeLog EXCEPTIONS-CLIENT ltconfig mysys support-files

client extra ltmain.sh netware tests

config.guess heap Makefile.am os2 tools

config.h.in include Makefile.in pstack vio

config.sub innobase man readline

configure install-sh merge README

[root@localhost mysql-4.0.27]#

INSTALL-SOURCE這裡面有你需要的安裝指令

添加mysql使用者組

[root@localhost mysql-4.0.27]# groupadd mysql

You have mail in /var/spool/mail/root

添加mysql使用者 并指定到mysql組中

[root@localhost mysql-4.0.27]# useradd -g mysql mysql

[root@localhost mysql-4.0.27]# echo "/* Linuxthreads */" &gt;&gt; /usr/include/pthread.h

你也可以直接運作下面這條指令直接執行編譯準備,如果有錯誤,試試上面得陰影部分指令

[root@localhost mysql-4.0.27]# ./configure --prefix=/usr/local/mysql

編譯前的準備,指定安裝目錄到/usr/local/mysql

試計算機性能不同,時間略有差别

<a href="http://yuzeying.blog.51cto.com/attachment/200905/1/644976_1241165681AYqQ.jpg"></a>

[root@localhost mysql-4.0.27]# make

編譯過程

<a href="http://yuzeying.blog.51cto.com/attachment/200905/1/644976_1241165684XlD9.jpg"></a>

[root@localhost mysql-4.0.27]# make install

編譯安裝 稍等

<a href="http://yuzeying.blog.51cto.com/attachment/200905/1/644976_12411656879av3.jpg"></a>

[root@localhost mysql-4.0.27]# cp support-files/my-medium.cnf /etc/my.cnf

複制mysql配置檔案

[root@localhost mysql-4.0.27]# cd /usr/local/mysql

進入安裝目錄

[root@localhost mysql]# bin/mysql_install_db --user=mysql

使用mysql使用者 初始化資料庫

Preparing db table

Preparing host table

Preparing user table

Preparing func table

Preparing tables_priv table

Preparing columns_priv table

Installing all prepared tables

090501 15:30:45 /usr/local/mysql/libexec/mysqld: Shutdown Complete

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:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

See the manual for more instructions.

You can start the MySQL daemon with:

cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &amp;

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:

cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

The latest information about MySQL is available on the web at

[url]http://www.mysql.com[/url]

Support MySQL by buying support/licenses at [url]http://shop.mysql.com[/url]

[root@localhost mysql]#

[root@localhost mysql]# chown -R root .

改變目前目錄的所有屬主為root

-R 為遞歸(即其下所有的子檔案的屬主也随之改為root)

[root@localhost mysql]# chown -R mysql var

改變var的屬主為mysql

[root@localhost mysql]# chgrp -R mysql .

改變目前目錄的屬組為mysql

[root@localhost mysql]# bin/mysqld_safe --user=mysql &amp;

背景啟動mysql服務 &amp;為背景啟動

[1] 17776

[root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/var

[root@localhost mysql]# /usr/local/mysql/bin/mysql

登陸到mysql資料庫

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

Your MySQL connection id is 1 to server version: 4.0.27-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql&amp;gt;

mysql&amp;gt; show databases ;

基本的檢視資料庫指令

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

| Database |

| mysql |

| test |

2 rows in set (0.00 sec)

mysql&amp;gt; ?

查詢指令

For the complete MySQL Manual online visit:

[url]http://www.mysql.com/documentation[/url]

For info on technical support from MySQL developers visit:

[url]http://www.mysql.com/support[/url]

For info on MySQL books, utilities, consultants, etc. visit:

[url]http://www.mysql.com/portal[/url]

List of all MySQL commands:

(Commands must appear first on line and end with ';')

help (\h) Display this help.

? (\?) Synonym for `help'.

clear (\c) Clear command.

connect (\r) Reconnect to the server. Optional arguments are db and host.

edit (\e) Edit command with $EDITOR.

ego (\G) Send command to mysql server, display result vertically.

exit (\q) Exit mysql. Same as quit.

go (\g) Send command to mysql server.

nopager (\n) Disable pager, print to stdout.

notee (\t) Don't write into outfile.

pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.

print (\p) Print current command.

prompt (\R) Change your mysql prompt.

quit (\q) Quit mysql.

rehash (\#) Rebuild completion hash.

source (\.) Execute a SQL script file. Takes a file name as an argument.

status (\s) Get status information from the server.

system (\!) Execute a system shell command.

tee (\T) Set outfile [to_outfile]. Append everything into given outfile.

use (\u) Use another database. Takes database name as argument.

Connection id: 2 (Can be used with mysqladmin kill)

mysql&amp;gt; quit

Bye

退出資料庫

本文轉自 yuzeying1 51CTO部落格,原文連結:http://blog.51cto.com/yuzeying/154611