您好,登錄后才能下訂單哦!
本文主要給大家介紹LAMP概況及MySQL安裝教程,其所涉及的東西,從理論知識來獲悉,有很多書籍、文獻可供大家參考,從現(xiàn)實意義角度出發(fā),億速云累計多年的實踐經(jīng)驗可分享給大家。
LAMP=Linux+Apache(httpd)+MySQL+PHP
Apache與httpd是相輔相成的,必須在一起
Apache+MySQL+PHP可以同時安裝在一臺機器上;
源文件:http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
模塊支持安裝包:perl-Data-Dumper.x86_64
[root@shu-test ~]# cd /usr/local/src/
[root@shu-test src]# ls
httpd-2.2.34 httpd-2.2.34.tar.gz
[root@shu-test src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
[root@shu-test src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
[root@shu-test src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
[root@shu-test src]# ls /usr/local/
apache2 bin etc games include lib lib64 libexec mysql sbin share src
[root@shu-test src]# ls /usr/local/mysql/
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@shu-test src]#
注意:/usr/local/mysql中的mysql不要提前創(chuàng)建,一定要是沒有此文件夾才能移動;否則/mysql文件夾下面是/mysql-5.6.36-linux-glibc2.5-x86_64文件夾;
新建一個mysql用戶,用來方便后面調(diào)用mysql數(shù)據(jù)庫
useradd mysql
[root@shu-test src]# cd /usr/local/mysql/
[root@shu-test mysql]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@shu-test mysql]#
[root@shu-test mysql]# mkdir /data/
[root@shu-test mysql]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@shu-test mysql]#
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
將mysql的使用者用戶名指定為mysql,數(shù)據(jù)庫目錄指定為剛剛創(chuàng)建的/data/mysql目錄;
[root@shu-test mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[root@shu-test mysql]#
此時提示缺少Dumper模塊
yum list |grep perl |grep -i dumper
列出含有perl模塊,不區(qū)分大小寫的dumper包;
[root@shu-test mysql]# yum list |grep perl |grep -i dumper
perl-Data-Dumper.x86_64 2.145-3.el7 base
perl-XML-Dumper.noarch 0.81-17.el7 base
[root@shu-test mysql]#
yum install -y perl-Data-Dumper.x86_64
[root@shu-test mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@shu-test mysql]# echo $?
0
[root@shu-test mysql]#
[root@shu-test mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆蓋"/etc/my.cnf"? n
[root@shu-test mysql]# ls /etc/my.cnf
/etc/my.cnf
[root@shu-test mysql]#
[root@shu-test mysql]# vim /etc/my.cnf
[root@shu-test mysql]# cat /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
> symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d
[root@shu-test mysql]#
將datadir與socket修改,其他注釋掉;
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld1指定目錄
basedir=/usr/local/mysql
datadir=/data/mysql
2添加開機啟動項mysql
chkconfig --add mysqld
3查看開機啟動項
chkconfig --list
如果看到mysql服務(wù),345都是on則是成功;
指定345開啟命令
chkconfig --level 345 mysql on
開啟mysqld服務(wù)
service mysqld start
查詢mysql是否啟動
ps aux |grep mysqld
查詢啟動服務(wù)的端口
netstat -lntp
關(guān)閉mysql服務(wù)
killall mysqld看了以上LAMP概況及MySQL安裝教程介紹,希望能給大家在實際運用中帶來一定的幫助。本文由于篇幅有限,難免會有不足和需要補充的地方,大家可以繼續(xù)關(guān)注億速云行業(yè)資訊板塊,會定期給大家更新行業(yè)新聞和知識,如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時售前售后,隨時幫您解答問題的。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。