37, lamp architecture, MYSQL-MARIADB Introduction, MySQL installation,

Source: Internet
Author: User
Tags php and mysql

37, lamp architecture, MYSQL-MARIADB Introduction, MySQL installation,

First, lamp architecture

Lamp=linux+apache (httpd) +mysql+php

That is, Apache, MySQL, PHP installed on Linux, an environment to run the PHP scripting language, usually the Web site.

Linux: Operating system. CentOS, Ubuntu is the Linux operating system.

Apache: Software that provides external services, real name httpd, commonly used Web services software.

MySQL: Database software. It is not the picture file that is stored, the data, the string.

PHP: scripting language. Similar to shell, but more complex than shell. Usually to do the site-based.

can be apache+php installed on one machine, MySQL installed on another machine, or three can be installed on one machine, but Apache and PHP need to be installed on the same machine because PHP is present as a module of Apache, they must be installed together.

Apache can not deal with MySQL , only through the PHP module Exchange data, Apache again to the user. This behavior of fetching data is called "Dynamic Request".

Dynamic request, parsing: For example, login to a Web site, enter a user name and password, and then Apache to the database comparison, at this time is through the PHP and MySQL to deal with the data, first find out what your password in the database, and then PHP to compare, and then Apache feedback to you a login status.

Static files, parsing: such as the site of the logo, but also to Apache request, the logo is present in a directory on the Linux server, get the picture and then feedback to the user. The process did not deal with MySQL.

Ii. introduction of MYSQL-MARIADB

MySQL: A relational database, developed by MySQL AB, was acquired by Sun Company in 2008 (1 billion knives) and acquired by Oracle Corporation in 2009 (7.4 billion knives).

MySQL Website: https://www.mysql.com

MARIADB is a branch of MySQL, the official website https://mariadb.com

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

The MariaDB5.5 version corresponds to MySQL's 5.5,mariadb10.0 corresponding to MySQL 5.6.

Community Community Edition; Enterprise Edition;

GA (generally Available) General edition, used in production environment;

DMR (Development Milestone release) development milestone release;

RC (Release Candidate) Release Candidate version;

Beta open test version; Alpha Internal beta version.

Third, MySQL installation

Common installation packages for MySQL: rpm, source code, binary-free compilation.

the benefits of binary-free compiler packages: You don't have to spend too much time configuring the compilation, you can use it directly. the installation path can be specified and RPM packages are not supported.

If you want to pursue performance, compile yourself, if there are no special requirements in the work, install this binary-free compiler package.

# CD/USR/LOCAL/SRC

5.6_64 bits binary Package: http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

# tar zvxf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

# MV Mysql-5.6.36-linux-glibc2.5-x86_64/usr/local/mysql

# Cd/usr/local/mysql

# useradd MySQL

# mkdir/data/stored mysql data, LS can be viewed to have this directory, you can omit this step.

#./scripts/mysql_install_db--user=mysql--datadir=/data/mysql

FATAL Error:please Install the following Perl modules before executing./SCRIPTS/MYSQL_INSTALL_DB:

Data::D umper initialization, in effect, is to generate/data/mysql this directory. This is the MySQL database directory, just like the KeePass password database. At this point a module is missing, the module is called Dumper.

Solution: When the package or module is less, and do not know the name of the module, first fuzzy search: # Yum list |grep perl |grep-i dumper, do not know whether dumper is uppercase or lowercase, plus-I is not case-sensitive, this method does not necessarily work but to try, If not, put this section to Www.bing.com, www.google.com (Google can't open), http://coderschool.cn/1853.html (Google's image, you can go to this site search)

# Yum List |grep perl |grep-i dumper

perl-data-dumper.x86_64 2.145-3.EL7 Base

Perl-data-dumper-concise.noarch 2.020-6.el7 Epel

Perl-data-dumper-names.noarch 0.03-17.el7 Epel

Perl-xml-dumper.noarch 0.81-17.EL7 Base

At this time to find out four, if you do not know which one, just try one, here need to install the 1th.

# yum Install-y perl-data-dumper.x86_64

#./scripts/mysql_install_db--user=mysql--datadir=/data/mysql to initialize again

When you don't know if this step has executed successfully, the first method, see there is no two ok, the second,echo $? (Must be after the first knock on the above command and then lose, right is 0)

/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-DEFAULT.CNF Template configuration file

# CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF actually/etc/under this my.cnf, which is the default installation of CENTOS7, can be used, but to change the configuration.

# VIM/ETC/MY.CNF

[Mysqld]

datadir=/data/mysql modified to/data/mysql

socket=/tmp/mysql.sock modified to/tmp/mysql.sock

# Disabling Symbolic-links is recommended to prevent assorted security risks

Symbolic-links=0

# Settings user and group was ignored when Systemd was 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 comment out, it's no use.

#pid-file=/var/run/mariadb/mariadb.pid comment out, it's no use.

#

# include all files from the Config directory

#

#!includedir/etc/my.cnf.d

# CP SUPPORT-FILES/MYSQL.SERVER/ETC/INIT.D/MYSQLD Copy the boot script template past

To customize the startup script, the first step is to put it under/etc/init.d/and then configure it.

# VIM/ETC/INIT.D/MYSQLD Press the arrow keys to find the following two items

basedir=/usr/local/mysql Set Base address

datadir=/data/mysql Setting up the database directory

The others do not need to be modified, the two saved can be changed.

# chmod 755/etc/init.d/mysqld here because it defaults to 755, so there's no need to modify it.

# chkconfig--add mysqld If you want it to boot, put it on the system service list.

# Chkconfig--list can see

You can also use the command to start it:/etc/init.d/mysqld start, service mysqld start

If you do not put the startup script or not put under the/etc/init.d/, you can use the following example to start:

Start with the command line

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql--datadir=/data/mysql &

--defaults-file=/etc/my.cnf specifying the path where the configuration file resides

How to stop this MySQL service:

#/etc/init.d/mysqld Stop

If opened on the command line, only # Killall mysqld

Killall: Kill process Command, more secure, such as in real-time read and write data, write data stored in memory, not cached to disk, Killall will first stop the current operation, and so on the data is written to the disk to kill the process.

Experience Sharing : If mysqld process Kill, PS there are processes, indicating a large amount of data, but also slowly write to disk, do not use kill-9 to kill the process, otherwise you may lose data and damage to your table, slowly wait on it.

There are two commonly used engines for MySQL: InnoDB (large storage, similar to Oracle), and MyISAM (less memory)


37, lamp architecture, 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.