<b>在</b><b>Linux</b><b>下安裝</b><b>mysql</b><b>的二進制源代碼包</b>
在Linux下安裝mysql的二進制源代碼包,看看我的安裝步驟吧!
<b>1. </b><b>下載下傳</b>
<b>2. </b><b>把下載下傳的檔案放在你的</b><b>/home/soft</b><b>目錄</b>
在終端輸入ls,如下:
[root@MysqlDBServer soft]# ls
mysql-max-5.0.24-linux-i686.tar.gz
<b>3. </b><b>然後用</b><b>tar -zxvf mysql-max-5.0.24-linux-i686.tar.gz</b><b>指令解壓到目前目錄</b>
[root@localhost mysql]# tar –zxvf mysql-max-5.0.24-linux-i686.tar.gz
mysql-max-5.0.24-linux-i686 mysql-max-5.0.24-linux-i686.tar.gz
<b>4. </b><b>因為用的是源代碼,是以要把檔案</b><b>copy</b><b>到安裝目錄</b><b>/usr/local/</b><b>下,才能運作</b><b>!</b>
[root@localhost mysql]# cp –rf mysql-max-5.0.24-linux-i686 /usr/local/
[root@localhost mysql]# cd /usr/local
[root@db2 local]# mv mysql-max-5.0.24-linux-i686 mysql(目錄改名成mysql)
<b>5. </b><b>檢視系統有沒有安裝過</b><b>mysql,</b><b>查找并删除原來的</b><b>rpm</b><b>形式的</b><b>mysql</b>
[root@localhost mysql]# rpm –qa | grep mysql
有的話一個一個删除掉,用rpm -e指令,然後查找一下殘留的檔案:
[root@localhost mysql]# cd /
[root@localhost /]# find / -name mysql
如果查找到rm -rf filename删除.
[root@localhost /]# find / -name my.cnf
如果查找到删除,一般my.cnf是在/etc/my.cnf這裡.
<b>6. </b><b>建立</b><b>mysql</b><b>使用者</b>
[root@localhost mysql]#useradd mysql
[root@localhost mysql]#passwd mysql(密碼為mysql)
7. <b>初始化</b><b>mysql</b><b>表格,安裝</b><b> mysql </b><b>預設資料庫,如下:</b>
[root@localhost mysql]# cd /usr/local/mysql
Installing all prepared tables
Fill help tables
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 MysqlDBServer password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
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 ./bin/mysqlbug .!
The latest information about MySQL is available . the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[root@MysqlDBServer mysql]#
<b>8. </b><b>修改目錄權限,如下:</b>
[root@localhost local]# chgrp -R mysql mysql
[root@localhost local]# chown -R mysql mysql/data
[root@localhost local]# ln -sv /usr/local/mysql/bin/* /usr/local/bin/
<b>9. </b><b>啟動</b><b>mysql_safe,</b><b>如下:</b>
[root@localhost local]# bin/mysqld_safe --user=mysql --socket=/tmp/mysql.sock --port=3306 &
[1] 26860
[root@localhost local]# nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /usr/local/mysql/data
檢視一下 3308 端口是否已經在監聽:
netstat -anp|grep LISTEN
10. <b>添加到系統自啟動,如下</b>:
[root@localhost local]# cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost local]# chkconfig --add mysqld
檢視啟動程序清單
[root@MysqlDBServer soft]# chkconfig --list|grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
11. <b>啟動</b><b>mysql</b><b>服務程序</b><b>,</b><b>如下</b>:
[root@localhost local]# /etc/init.d/mysqld start
Starting MySQL [ OK ]
本文轉自 pgmia 51CTO部落格,原文連結:http://blog.51cto.com/heyiyi/126016