LAMP概况及MySQL安装教程
本文主要给大家介绍LAMP概况及MySQL安装教程,其所涉及的东西,从理论知识来获悉,有很多书籍、文献可供大家参考,从现实意义角度出发,创新互联累计多年的实践经验可分享给大家。
峰峰矿ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
LAMP简介
LAMP=Linux+Apache(httpd)+MySQL+PHP
Apache与httpd是相辅相成的,必须在一起
Apache+MySQL+PHP可以同时安装在一台机器上;
MySQL安装
源文件:http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
模块支持安装包:perl-Data-Dumper.x86_64
下载MySQL安装包
[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不要提前创建,一定要是没有此文件夹才能移动;否则/mysql文件夹下面是/mysql-5.6.36-linux-glibc2.5-x86_64文件夹;
创建mysql用户
新建一个mysql用户,用来方便后面调用mysql数据库
useradd mysql
创建/data目录
[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]#
安装数据库
指定mysql数据库的目录与用户名,错误提示处理;
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
将mysql的使用者用户名指定为mysql,数据库目录指定为刚刚创建的/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模块
查找dumper模块包
yum list |grep perl |grep -i dumper
列出含有perl模块,不区分大小写的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
继续执行指定目录与用户名,用echo $?检查命令是否成功
[root@shu-test mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@shu-test mysql]# echo $?
0
[root@shu-test mysql]#
复制配置模板到etc下(默认有)
[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]#
修改/etc/my.cnf配置文件
[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服务,345都是on则是成功;
指定345开启命令
chkconfig --level 345 mysql on
启动于关闭mysql服务
开启mysqld服务
service mysqld start
查询mysql是否启动
ps aux |grep mysqld
查询启动服务的端口
netstat -lntp
关闭mysql服务
killall mysqld看了以上LAMP概况及MySQL安装教程介绍,希望能给大家在实际运用中带来一定的帮助。本文由于篇幅有限,难免会有不足和需要补充的地方,大家可以继续关注创新互联行业资讯板块,会定期给大家更新行业新闻和知识,如有需要更加专业的解答,可在官网联系我们的24小时售前售后,随时帮您解答问题的。
网页名称:LAMP概况及MySQL安装教程
本文地址:http://cdiso.cn/article/ggpggh.html