Lamp architecture Introduction, MySQL, mariadb introduction, MySQL Installation

Source: Internet
Author: User
Tags parent directory php and mysql php script

Lamp Architecture Introduction

Lamp is a shorthand that contains 4 things: Linux, Apache (httpd), MySQL, PHP

Linux operating system, Apache provides WB service software, MySQL storage data software, PHP scripting language

How Lamp works
The browser sends an HTTP request to the server, and the server (Apache) accepts the request, because PHP is also launched as an Apache component module, and they have the same life cycle. Apache will save some static resources and then call the PHP processing module to do the PHP script processing. After the script is processed, Apache sends the processed information via HTTP response to the browser, browser parsing, rendering, and so on, rendering the entire Web page after a series of operations.

Between PHP and MySQL is a dynamic request (such as the user's login operation will be used)

If you just view the picture as a static request, PHP and MySQL dynamic requests will not be used. (MySQL cannot save files such as pictures)

MySQL, Mariadb Introduction

MySQL is a relational database developed by MySQL AB, which was acquired by Sun in 2008 (1 billion Knives), and 2009 Sun was acquired by Oracle (7.4 billion knives).

MySQL official website https://www.mysql.com latest version 5.7GA/8.0DMR

MySQL5.6 change relatively large, 5.7 performance has been greatly improved

MARIADB is a branch of MySQL, official website https://mariadb.com Latest Version 10.2

Mariadb mainly by Skysql Company (now renamed MARIADB Company) Maintenance, Skysql company by the MySQL original author led most of the original squad founded.

Mariadb5.5 version corresponds to MySQL 5.5,10.0 corresponding MySQL5.6

Community Community Edition, Enterprise Business Edition, GA (generally Available) refers to the generic version, used in production environments, DMR (development Milestone release) development milestone release, RC (Release Candidate) Release Candidate version, beta Open beta version, alpha internal beta version

MySQL Installation

Several common installation packages for MySQL: rpm, source code, binary-free compilation (easy to compile, no configuration, you can specify the path.) )

Because binary-free compilation is convenient and sufficient for normal use, we use binary cotton to compile

In order to facilitate future management, we unified the installation package download to/usr/local/src this directory down
cd /usr/local/src

Download the installation package, download the version for 5.6 x86_64
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

Unzip the downloaded package
tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

Move the extracted directory and change the name of MySQL (error prone, the MySQL file already exists in the local, if this move, will be moved to MySQL, this will be an error, before the MV advance into the local to see if there is already a MySQL folder)
mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql

Enter the MySQL directory to see what files are under MySQL

cd /usr/local/mysqlls

Create a data directory, you can see that the data directory already exists, then do not need to execute the command to create the directory
mkdir data

Create a MySQL user (named MySQL)
useradd mysql

Install MySQL, initialize, specify user as MySQL, specify data storage address/data/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

Here it hints at the lack of a Perl module, so we need to install it. If you do not know the package name needs a fuzzy search, first of all, this file is a Perl module, so it must contain Perl, also contains dumper (not sure case, plus-i)
yum list |grep perl |grep -i dumper

If you find 4, if you do not know which one is all loaded, here we know is the first package.

Packages that are dependent on the installation
yum install -y perl-Data-Dumper.x86_64

Then use the following command to initialize (sometimes error data of the parent directory does not exist, then in front of the/data/with an absolute path can be)
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

Copy mysql template configuration file, MySQL configuration file is stored under/etc/, and the name is fixed to MY.CNF, if you do not want to store in this directory, then the start of the need to specify the configuration file (there is already a my.cnf file, we select Y overwrite)
cp support-files/my-default.cnf /etc/my.cnf

Copy the script that starts
cp support-files/mysql.server /etc/init.d/mysqld

Edit Startup script
vi /etc/init.d/mysqld

Locate Basedir and DataDir to change the content as follows:
Basedir=/usr/local/mysql
Datadir=/usr/locat/mysql/data/mysql

Change the startup script configuration file to 755
chmod 755 /etc/init.d/mysqld

Add mysqld to open start
chkconfig --add mysqld

Start MySQL
1. Start MySQL with a command
service mysqld start

    1. Start with a script
      /etc/init.d/mysqld start

Stop MySQL
service mysqld stop

Start the script as a command line,--defaults-file specify the configuration file, specify the user, specify the directory, and finally add the & symbol to the background to execute
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &

The MySQL script started as a command line cannot be stopped directly, you can use Killall to stop the service

Using Killall stops the current write operation, writes data that is not written to the disk, and then kills the process after it is finished.

If you encounter the process of MySQL kill, it may indicate a large amount of data, slowly write to disk, this time do not use kill-9 force kill process, may corrupt data.
' Killall mysqld '

Lamp architecture Introduction, MySQL, mariadb introduction, MySQL Installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.