Linux下安裝資料庫

來源:互聯網
上載者:User

標籤:設定   lld   開啟   -o   disable   group   chown   new   root   

1:

查詢已安裝的mysql的資料包:  rpm -qa|grep -i mysql

資料庫的服務狀態:service  mysql stop/start/restart

卸載已安裝的資料庫

命令:rpm -e ;        rpm -e --nodeps (強制卸載資料包)

刪除舊版本的mysql檔案和庫

rpm -rf  /usr/lib/mysql

rpm -rf /usr/share/mysql

rpm -rf /var/lib/mysql

注意卸載後的/etc/my.cnf不會自動刪除,需要手動刪除

rm -rf /etc/my.cnf

再檢查數機器是否安裝了mysql

rpm -qa|grep -i mysql   (沒有結果則顯示徹底刪除了)

將mysql安裝包上傳至/var/lib目錄下,並進行解壓

cd /var/lib

tar -zvxf   安裝包

更改名稱

mv  安裝包名  mysql

添加使用者和使用者組(如果存在則使用 vi /etc/passwd 或 vi /etc/group 進行查詢)

groupadd mysql

useradd  -r -g mysql mysql

進入mysql檔案修改使用者權限和組許可權

chown  -R  mysql.

chgrp -R mysql.

安裝完成之後,讓mysql隨著系統自動啟動

  chkonfig   --levels 235 mysqld on

  /etc/init.d/mysqld start

設定mysql資料庫root賬戶的密碼:

mysql_secure_installation

當出現“Enter current password for root:”直接按斷行符號鍵

出現如下再次斷行符號

Set root password?[Y/N]

出現如下提示你需要輸入密碼,斷行符號之後再次輸入密碼

New password:

接下來會出現4個確認:

Remove anonymous users? [Y/n]

Disallow root login remotely? [Y/n]

Remove test database and access to it? [Y/n]

Reload privilege tables now? [Y/n]

直接敲斷行符號鍵即可

備忘:

查看啟動狀態[[email protected]localhost ~]#  service mysqld status

啟動、關閉、重啟[[email protected]localhost ~]#  service mysqld stop/start/restart

進入mysql介面:[[email protected]localhost ~]#  mysql -uroot –p  

關閉防火牆[[email protected] ~]# service iptables stop  使用sqlyog測試連接。

 

 

輸入ifcongfig中的ip地址在瀏覽器中即可顯示TestPage

 安裝Apache組件

由於Centos已經封裝了Apche,直接運行安裝

yum  install  httpd

同樣配置Apache隨著系統自動啟動

chkconfig  --levels 235 httpd on

/etc/init.d/httpd start

此時已經可以訪問你的伺服器,不出意外的話,能夠看到 “Apache 2 Test Page powered by CentOS” 的測試頁面。注意,如果其他機器訪問這台服務無法顯示這個頁面,而直接在這台伺服器上可以訪問的話,一般情況下是 CentOS 內建的防火牆禁止了。你只需要進入防火牆,將 “WWW” 對應的 “80” 連接埠開啟即可。

 

注意:在 CentOS 中 Apache 的預設根目錄是 /var/www/html,設定檔 /etc/httpd/conf/httpd.conf。其他配置儲存在 /etc/httpd/conf.d/ 目錄。

 

備忘:從其他機器訪問需要修改成IP訪問和關閉防火牆

 

[[email protected]localhost ~]# vi  /etc/httpd/conf/httpd.conf   

 

 將#ServerName www.example.com:80 中的“#”刪掉,並將 www.example.com 改為原生ip地址(可以把兩個地方的80連接埠改成8080)

 

 [[email protected] ~]# /etc/init.d/httpd restart

 

關閉防火牆:

 

[[email protected]localhost ~]# service iptables stop         #停止
[[email protected]localhost ~]# chkconfig iptables off        #禁用

 

如果是centos 7版本
[[email protected]localhost ~]# systemctl stop firewalld.service               #停止
[[email protected]localhost ~]# systemctl disable firewalld.service          #禁用

 

 

 

 

 安裝php:

yum install php

/etc/init.d/httpd restart

需要安裝PHP的擴充:

[[email protected]localhost ~]#  yum install php-mbstring

-----mbstring在sugar需要支援

修改php.ini檔案:

vi /etc/php.ini

upload_max_filesize = 2M 改為 6M ----------sugar需求

測試PHP相關資訊

這步實際上可以省略,但是為了測試是否安裝成功,你可以建立一個 PHP 頁面進行測試,使用 vim 編輯器建立:

vi /var/www/html/info.php

 

按 “i” 鍵進行編輯,輸入:

 

<?php

 

phpinfo();

 

?>

 

編輯完畢,按 “ESC” 鍵退出編輯模式,接著輸入:

 

:wq

 

然後斷行符號,即儲存並退出。

 

  此時你可以訪問你的網站地址,例如 “http://192.168.1.2/info.php”,查看是否能看到相關的 PHP 資訊。

 

將PHP和mysql模組串連起來

yum  search php

安裝相關模組:

yum install php-mysql  php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

重啟Apache模組才會生效

/etc/init.d/httpd restart

 

 在centos上安裝為yum install XXX,相對卸載即為yum remove XXX。

Linux下安裝資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.