About Lamp
Lamp=linux+apache (httpd) +mysql+php
Apache and httpd are complementary and must be together.
Apache+mysql+php can be installed on a single machine at the same time;
MySQL Installation
Source file: http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
Module Support installation package: perl-data-dumper.x86_64
Download the MySQL installation package
[[email protected] ~]# cd /usr/local/src/[[email protected] src]# lshttpd-2.2.34 httpd-2.2.34.tar.gz[[email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
Unzip and move the rename to the installation path
[[email protected] src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz[[email protected] src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql[[email protected] src]# ls /usr/local/apache2 bin etc games include lib lib64 libexec mysql sbin share src[[email protected] src]# ls /usr/local/mysql/bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files[[email protected] src]#
Note: MySQL in/usr/local/mysql do not create in advance, must not have this folder to move, otherwise/mysql folder is/mysql-5.6.36-linux-glibc2.5-x86_64 folder;
Create a MySQL user
Create a new MySQL user to make it easy to call MySQL database later
useradd mysql
Create a/data directory
[[email protected] src]# cd /usr/local/mysql/[[email protected] mysql]# lsbin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files[[email protected] mysql]#[[email protected] mysql]# mkdir /data/[[email protected] mysql]# lsbin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files[[email protected] mysql]#
The installation database specifies the directory of the MySQL database with the user name, error handling;
./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
The MySQL user name is specified as MySQL, and the database directory is specified as the/data/mysql directory you just created;
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysqlFATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:Data::Dumper[[email protected] mysql]#
The missing dumper module is now indicated
Find the Dumper module package
Yum List |grep perl |grep-i dumper
List dumper packets containing Perl modules, case-insensitive;
[[email protected] mysql]# yum list |grep perl |grep -i dumperperl-Data-Dumper.x86_64 2.145-3.el7 base perl-XML-Dumper.noarch 0.81-17.el7 base [[email protected] mysql]#
Install module Support Package
yum install -y perl-Data-Dumper.x86_64
Continue execution of the specified directory with the user name, with echo $? Check if the command is successful
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql[[email protected] mysql]# echo $?0[[email protected] mysql]#
Copy configuration template to etc (default)
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnfcp:是否覆盖"/etc/my.cnf"? n[[email protected] mysql]# ls /etc/my.cnf/etc/my.cnf[[email protected] mysql]#
Modifying the/ETC/MY.CNF configuration file
[[email protected] mysql]# vim /etc/my.cnf[[email protected] 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[[email protected] mysql]#
Modify the DataDir with the socket, other comments out;
Set boot up
CP Support-files/mysql.server/etc/init.d/mysqld
Vim/etc/init.d/mysqld
1 Specifying a directory
Basedir=/usr/local/mysql
Datadir=/data/mysql
2 Add boot entry MySQL
Chkconfig--add mysqld
3 Viewing Boot Startup items
Chkconfig--list
If you see the MySQL service, 345 is on is the success;
Specify 345 to open the command
Chkconfig--level 345 MySQL on
Start on shutdown MySQL service
Open MYSQLD Service
Service mysqld Start
Query whether MySQL is started
PS aux |grep mysqld
Querying the port that started the service
Netstat-lntp
Turn off MySQL service
Killall mysqld
Introduction to lamp and MySQL installation