Linux下安裝、啟動MySQL


三四年沒有安裝過mysql+apache+PHP的環境了,我以前是做銀行性能測試外包服務的,在甲方開發中心遇到這樣環境的項目也比較少,大多是WebLogic/WebSphere+Oracle/DB2架構的大型系統。涉足電商行業方面的項目,不得不再去溫故那些幾乎遺忘的IIS、apache、MSsql、mysql等環境。

平台:VMware上虛擬的centos4.7

宿主機:windows

安裝mysql前准備:

1、檢查該環境中是否已安裝mysql,檢查方法:netstat –ano命令查看mysql默認端口3306是否存在;或者再命令行中執行mysql

2、下載mysql安裝包

http://www.mysql.com/downloads/mysql/#downloads下載mysql安裝包:

MySQL-server-5.5.28-1.linux2.6.i386.rpm

MySQL-client-5.5.28-1.linux2.6.i386.rpm

使用rpm –ivh命令來安裝mysql,這里不說啦。

先來了解一下mysql數據庫默認的一些主要目錄:

1、數據庫目錄 /var/lib/mysql/

2、配置文件  /usr/share/mysql(mysql.server命令及配置文件)

3、相關命令  /usr/bin (mysqladmin mysqldump等命令)

4、啟動腳本  /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>

啟動與停止

1、啟動
  MySQL安裝完成后啟動文件mysql在/etc/init.d目錄下,在需要啟動時運行下面命令即可。  

[root@localhost mysql]#  /etc/init.d/mysql start

2、停止  

[root@localhost mysql] #  /usr/bin/mysqladmin -u root -p shutdown

3、自動啟動

  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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM