Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction of LAMP Architecture of linux and installation of mysql

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Introduction to LAMP Architecture

LAMP is the abbreviation of Linux+Apache (httpd) + MySQL+PHP, that is, Apache, MySQL and PHP are installed on the linux system to form a running environment to run the PHP scripting language, usually a website. For example, Google, Taobao, Baidu, 51cto blog, ape forum and so on are written in PHP language.

The three roles of httpd, PHP, and MySQL can be on the same machine or separately, but httpd and PHP are to be installed on the same machine, which is also the existence of PHP as a module of Apache, and they must be together.

How do httpd, PHP and MySQL work:

PHP is combined with Apache in the form of modules.

Apache cannot deal with Mysql directly. It can only go to Mysql through the PHP module to get data, and then give it to Apache and then to the user. There is a dynamic request between PHP and Mysql.

Introduction to MySQL and MariaDB

MySQL is a relational database developed by mysql ab. Mysql was acquired by sun in 2008 ($1 billion) and sun by oracle in 2009 ($7.4 billion).

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

MySQL5.6 has changed greatly, and its performance has been greatly improved.

Mariadb is a branch of MySQL. The latest version of https://mariadb.com/ is 10.2.

MariaDB is mainly maintained by SkySQL (now renamed MariaDB). SkySQL was founded by most of the original people led by the original author of MySQL.

The version of Mariadb5.5 corresponds to the 5.5 of MySQL and 10.0 corresponds to MySQL5.6.

Community community version, Enterprise enterprise version, GA (Generally Available) refers to general version, used in production environment, DMR (Development Milestone Release) development milestone release, RC (Release Candidate) release candidate, Beta open test, Alpha internal test MySQL installs MySQL installs several common installation packages of MySQL: rpm package, source package, binary uncompiled package to check how many bits are in the linux system: [root@gary ~] # uname-aLinux gary 3.10.0-514.el7.x86_64 # 1 SMP Tue Nov 22 16:42:41 UTC 2016 x86 "64 GNU/Linux

two。 Download the mysql source package and put the installation package in the specified directory:

[root@gary ~] # cd / usr/local/src [root@gary src] # wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz--2017-12-14 1914 root@gary-http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz is parsing the master Computer mirrors.sohu.com (mirrors.sohu.com). 221.236.12.140 mirrors.sohu.com (mirrors.sohu.com) is being connected | 221.236.12.140 |: 80. Connected. A HTTP request has been issued Waiting for a response. 200 OK length: 314581668 (300m) [application/octet-stream] is being saved to: "mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz" 100% [= = >] 314581668 1.40MB/s 3m 34s 2017-12-14 19:20:49 (1.40MB/s)-saved "mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz" [314581668 application/octet-stream])

3. Extract the compressed package:

[root@gary src] # tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

4. Move the directory to / usr/local/ and rename it to mysql:

[root@gary src] # mv mysql-5.6.35-linux-glibc2.5-x86_64 / usr/local/mysql

5. Enter the directory to view:

[root@gary src] # cd / usr/local/mysql [root@gary mysql] # lsbin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files

6. Create a mysql user and create a directory / data/, to store mysql data:

[root@gary mysql] # useradd mysql [root@gary mysql] # mkdir / data/

7. Initialize the specified user mysql and path:

[root@gary-tao 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 @ gary 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 [root@gary mysql] # yum install-y perl-Data-Dumper [root@gary-tao mysql] # echo $? / / verify that the last command was successful You need to test 0 [root@gary-tao mysql] #. / scripts/mysql_install_db-user=mysql-datadir=/data/mysql / / immediately before performing the error resolution.

Solution:

(this may happen after execution because a module is missing and requires us to install: yum install-y perl-Data-Dumper)

After executing the command, you can immediately execute the command echo $? Check whether it is 0, which means the execution is successful.

Packages that may be missing:

Yum install-y libaio

Yum install-y numactl

Yum-y install libaio-devel

Yum-y install openssl-devel

Yum-y install perl perl-devel

To install centos 6.5, you can read the following article:

Http://www.cnblogs.com/bookwed/p/5896619.html

There are two ways to copy the configuration file:

Method 1:

Copy the configuration file to cp support-files/my-default.cnf / etc/my.cnf in the etc directory

Method 2:

Change the included vim / etc/my.cnf file to the following configuration:

9. Copy the startup script to the / etc/init.d directory and rename it mysqld:

[root@gary-tao mysql] # cp support-files/mysql.server / etc/init.d/mysqld

10. Edit the startup script:

[root@gary-tao mysql] # vi / etc/init.d/mysqld

Define basedir and datadir

Basedir=/usr/local/mysql

Datadir=/data/mysql

11. Start mysql:

Check to see if the default permission is 755 and add the service to boot. Root@gary-tao mysql] # ls-l / etc/init.d/mysqld / / default permissions-rwxr-xr-x 1 root root 10902 December 14 20:57 / etc/init.d/mysqld [root@gary-tao mysql] # chkconfig-- add mysqld / / add boot [root@gary-tao mysql] # chkconfig-- list / / check that boot has been added Note: this output only shows SysV services and does not include native systemd services. SysV configuration data may be overwritten by native systemd configurations. If you want to list systemd services, execute 'systemctl list-unit-files'. To view the services enabled for a particular target, execute 'systemctl list-dependencies [target]'. Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off netconsole 0: off 1: off 2: on 3: off 4: off 5: off 6: off 1: off 2: on 3: on 4: on 6: off 1: close 2: on 3: on 4: on 6: turn off manually start mysql service commands [root@gary mysql] # / etc/init.d/mysqld start or service mysqld start [root@gary mysql] # service mysqld start / / Service started successfully Starting MySQL.Logging to'/ data/mysql/gary.err'. SUCCESS! [root@gary mysql] # ps aux | grep mysql/ / View process root 8081 0.0 11760 1588 pts/0 S 21:23 0:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- datadir=/data/mysql-- pid-file=/data/mysql/gary.pidmysql 8216 0.9 44.9 973048 449520 pts/0 Sl 21:23 0:05 / usr/local/mysql/bin/mysqld-- basedir=/usr/ Local/mysql-- datadir=/data/mysql-- plugin-dir=/usr/local/mysql/lib/plugin-- user=mysql-- log-error=/data/mysql/gary.err-- pid-file=/data/mysql/gary.pid-- socket=/tmpmysql.sockroot 8258 0.0 112664 972 pts/0 S+ 21:32 0:00 grep-- color=auto mysql [root@gary mysql] # netstat-lntp / / View listening port 3306Active Internet connections (only servers) Proto Recv -Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0 LISTEN 22 0.0.0.0 LISTEN 1102 / Master tcp6 0 0: 3306: * LISTEN 8216/mysqld tcp6 0 0: 22: * LISTEN 827/sshd tcp6 0 0:: 1:25:: * LISTEN 1102/master

Suppose:

If there is no startup script to put under / etc/init.d, then you can use the command to open mysql (PS: command mode mysql to close the need to use the kill command: killall mysqld, you can also use the kill PID number, but it is recommended to use killall, just as if mysql uses killall, it will first stop the current read and write operations, and then slowly write the data that has not been written to disk until the writing is finished. If you encounter the mysqld process can not be killed, wait a minute can not be killed, indicating a large amount of data, wait slowly, do not force the use of kill-9. )

Command:

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

-defaults-file: specify the path where the configuration file is located.

Examples are as follows:

[root@gary mysql] # service mysqld stop / / stop mysql service Shutting down MySQL.. SUCCESS! [root@gary mysql] # ps aux | grep mysql/ / View process stop root 8290 0.0 112664 968 pts/0 S+ 21:38 0:00 grep-- color=auto mysql [root@gary mysql] # / usr/local/mysql/bin/mysqld_safe-- defaults-file=/etc/my.cnf-- user=mysql-- datadir=/data/mysql & / / execute the command to start the service Press ctrl+z to put the command in the background to execute [1] 8472 [root@gary mysql] # 171214 21:42:10 mysqld_safe Logging to'/ data/mysql/gary.err'.171214 21:42:10 mysqld_safe Starting mysqld daemon with databases from / data/mysql [root@gary mysql] # ps aux | grep mysql/ / process startup root 8472 0.00.1 113256 1584 pts/0 S 21:42 0:00 / bin/sh / usr/local/mysql/ Bin/mysqld_safe-defaults-file=/etc/my.cnf-user=mysql-datadir=/data/mysqlmysql 8595 0.3 45.6 973048 456372 pts/0 Sl 21:42 0:00 / usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql-datadir=/data/mysql-plugin-dir=/usr/local/mysql/lib/plugin-user=mysql-log-error=/data/mysql/gary.err-- Pid-file=/data/mysql/gary.pid-- socket=/tmp/mysql.sockroot 8620 0.0 112664 968 pts/0 S+ 21:46 0:00 grep-- color=auto mysql [root@gary mysql] # yum install psmisc / / install the killall command [root@gary mysql] # killall mysqld / / terminate the mysql service started by command [root@gary mysql] # ps aux | grep mysql/ / View process has ended root 8642 0.0 112664 972 pts/0 R + 21:54 0:00 grep-- color=auto mysql

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 280

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report