三四年沒有安裝過mysql+apache+PHP的環境了,我之前是作銀行性能測試外包服務的,在甲方開發中心遇到這樣環境的項目也比較少,大可能是WebLogic/WebSphere+Oracle/DB2架構的大型系統。涉足電商行業方面的項目,不得再也不去溫故那些幾乎遺忘的IIS、apache、MSsql、mysql等環境。mysql
平臺:VMware上虛擬的centos4.7linux
宿主機:windowssql
安裝mysql前準備:數據庫
一、檢查該環境中是否已安裝mysql,檢查方法:netstat –ano命令查看mysql默認端口3306是否存在;或者再命令行中執行mysqlapache
二、下載mysql安裝包windows
在http://www.mysql.com/downloads/mysql/#downloads下載mysql安裝包:centos
MySQL-server-5.5.28-1.linux2.6.i386.rpm架構
MySQL-client-5.5.28-1.linux2.6.i386.rpmtcp
使用rpm –ivh命令來安裝mysql,這裏不說啦。性能
先來了解一下mysql數據庫默認的一些主要目錄:
一、數據庫目錄 /var/lib/mysql/
二、配置文件 /usr/share/mysql(mysql.server命令及配置文件)
三、相關命令 /usr/bin (mysqladmin mysqldump等命令)
四、啓動腳本 /etc/rc.d/init.d/(啓動腳本文件mysql的目錄)
安裝後經過netstat –ano命令查看mysql默認端口3306是否存在,若是不存在,按下面的方法啓動mysql服務。
啓動mysql服務:
[root@localhostmysql]# pwd /usr/share/mysql [root@localhostmysql]# ./mysql.server start StartingMySQL...[ 肯定 ] [root@localhostmysql]# netstat -ano ActiveInternet connections (servers and established) ProtoRecv-Q Send-Q Local Address Foreign Address State Timer tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN off (0.00/0/0) [root@localhostmysql]# mysql Welcometo the MySQL monitor. Commands end with; or \g. YourMySQL connection id is 1 Serverversion: 5.5.28 MySQL Community Server (GPL) Copyright(c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle isa 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>
啓動與中止
一、啓動
MySQL安裝完成後啓動文件mysql在/etc/init.d目錄下,在須要啓動時運行下面命令便可。
[root@localhost mysql]# /etc/init.d/mysql start
二、中止
[root@localhost mysql] # /usr/bin/mysqladmin -u root -p shutdown
三、自動啓動
1)察看mysql是否在自動啓動列表中
[root@localhost mysql] # /sbin/chkconfig –list
2)把MySQL添加到你係統的啓動服務組裏面去
[root@localhost mysql] # /sbin/chkconfig – add mysql
3)把MySQL從啓動服務組裏面刪除。
[root@localhost mysql] # /sbin/chkconfig – del mysql