Apache和MySQL都是非常受歡迎的開源軟件,它們可以很好地配合使用。在本文中,我們將簡要介紹如何在Apache上安裝MySQL。
步驟:
1. 下載MySQL,并解壓文件。 2. 將解壓后的文件夾復制到Apache的htdocs目錄下。 3. 修改MySQL目錄下的配置文件my.cnf,設置MySQL的root密碼,一般在[mysqld]下添加如下代碼: [mysqld] datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # 設置MySQL的根密碼 skip-grant-tables skip-networking bind-address = 127.0.0.1 port=3306
4. 啟動MySQL服務器:
$ cd /usr/local/mysql $ bin/mysqld_safe --user=mysql & $ # Next command is optional $ cp support-files/mysql.server /etc/init.d/mysql.server $ # Next command is optional $ /etc/init.d/mysql.server start
5. 驗證MySQl是否啟動成功。
$ ps ax | grep mysql 2752 ?? S 0:00.11 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql 2922 ?? S 0:00.04 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mysql08.local.err --pid-file=/usr/local/mysql/data/mysql08.local.pid 3615 s003 S+ 0:00.00 grep mysql
至此,Apache的MySQL安裝就完成了!