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

1. LAMP architecture introduction MySQL installation

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

[toc]

LAMP Architecture introduction MySQL installation 1. LAMP Architecture introduction 1.Linux+Apache (httpd) + MySQL+PHP

Appache is the most commonly used web service software, while MYSQL is a relatively small database software. Both software and PHP can be installed on windows machines.

1.1Common PHP websites (Google, Taobao, Baidu, 51cto blog, ape forum)

Extend:

What is a scripting language? Why is php a scripting language

Q: 1. Are scripting and programming languages and html the main categories of computer languages? What's the difference? The key is that php is a scripting language. Since I have just begun to learn php, I would like to ask the heroes to speak as easily as possible.

2. I want to do a more fully functional website, using an independent station system, but is it best to learn some php language?

Answer 1: programming languages are generally used to write application programs, such as C-Magi, C-Force, C-D, B-D, D-P-H-I, Java, etc., which are powerful and difficult to learn.

Scripting languages are generally used to write some simple applications, such as JS,VBS,JSP,ASP,PHP, and macro programs can also be regarded as scripting languages. The biggest disadvantage of scripting languages compared to programming languages is that they are inefficient, but easier to write.

HTML is not a language, although it is called Hypertext markup language, it is actually only a control tag, and what is written is not called a program.

There can also be VBS or JS scripts in static web pages, which are just foreground.

You can use both VBS and JS in ASP, but most people usually use VBS, which is in the background.

The syntax of PHP is almost the same as that of C, but in fact it is almost the same as that of JS.

If you want to do a website, you need to learn ASP (a little behind, but easy to get started) or at least one of PHP or JSP or ASP.net (you can learn VB.net or C#.net).

The free whole station system can be used and modified for free, but most of them are not allowed for commercial use. You can go to the corresponding official website to check the authorization documents.

Answer 2: C / B / C / C / B, etc. These belong to the programming language.

Scripting languages are mainly our common asp;php and so on.

Asp belongs to vb and is a subset of vb.

Php is developed using c

Both asp and php need server parsing execution, but html is different from them. Html does not need server parsing execution, it only needs to output directly, so we call html hypertext.

If the self-help site building system you use is developed by php, then if you want to develop complex websites, you'd better learn PHP, so you can rewrite the core of the site building system, but if you only use it as an ordinary enterprise site, it doesn't matter whether you learn php or not.

1.2The three roles can be on the same machine or separately (httpd and PHP are to be together). Apache and PHP need to be installed on the same machine, because PHP exists as a module of Apache, and how 2.httpd, PHP and MySQL work together

MySQL stores user names; passwords and data, pictures, etc., are stored in static files

11.2 introduction to MySQL_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 staff 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

11.4 MySQL installation 1. Download MySQL package 1.1 to view the system version: uname-I [root@localhost src] # uname-ix86_641.2 specify a general directory before downloading the source package, which holds all packages

What is a source package: source packages are modifiable C or C++ language source files, while compilation-free binary packages are compiled files that are packaged and provided to us. For example, QQ,360 installed on windows is this kind of installation package.

[root@localhost ~] # cd / usr/local/src [root@localhost src] # wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz2. Initialize 2.1Compression package [root@localhost src] # tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz2.2 move location to place the extracted files in the / usr/local/mysql/ directory [root@localhost src] # mv mysql-5.6.36-linux-glibc2.5-x86_64 / usr/local/mysql extension: update the mysql software version # [- d / usr/local/mysql ] & & mv / usr/local/mysql / usr/local/mysql_old

Similar to an if judgment, which means that if the / usr/local/mysql directory exists, change the name so as not to affect the later operation. If you do not change the original path name, the newly installed mysql step will fail.

2.3 check whether the / usr/local/mysql/ directory is correct, whether there are any extra files, and avoid misoperation of [root@localhost src] # cd / usr/local/mysql/ [root@localhost mysql] # lsbin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files2.4 to create a mysql user, because the user [root@localhost mysql] # useradd mysql is required to start MySQL.

The creation method in the book is: # useradd-s / sbin/nologin mysql

2.5 create / data/ directory and change permissions to store mysql data files, prepare [root@localhost mysql] # mkdir / data/# chown-R mysql:mysql / data/mysql / / to / data/mysql the folder service mysql user's execution permission 2.6.initialize mysql:./scripts/mysql_install_db-- user=mysql-- datadir=/data/mysql

-- user defines the master of the database.-- datadir defines where the database is installed. It is recommended to put it on a partition with large space. This directory needs to be created on its own.

During initialization, the following problems may occur:

[root@localhost mysql] #. / scripts/mysql_install_db-- user=mysql-- datadir=/data/mysqlFATAL ERROR: please install the following Perl modules before executing. / scripts/mysql_install_db:Data::Dumper2.7 how to determine whether the package or module is actually installed: missing Perl module, missing yum list for Dumper support | grep perl | grep-I dumper

So how to solve it?

Use fuzzy search and filter keys to try to solve:

[root@localhost mysql] # yum list | grep perl | grep-I dumperperl-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

The above four installation packages appear after the search is completed, and when you are not sure which installation package you need, you can try each installation package.

[root@localhost mysql] # yum install-y perl-Data-Dumper.x86_642.8 finds the installation package and reinitializes mysql

Execute:

[root@localhost mysql] #. / scripts/mysql_install_db-- user=mysql-- the first kind of datadir=/data/mysql, see two OK, confirm

Second, execute echo $? to see if there is a problem with the previous command [root@localhost mysql] # echo $? 03. Configure MySQL3.1 first copy the configuration file my-default.cnf [root@xavi mysql] # ls support-files/my-default.cnfsupport-files/my-default.cnf [root@xavi mysql] # cp support-files/my-default.cnf / etc/my.cnf edit the configuration file my.cnf,socket defines the socket address that the MySQL service listens to. Under the Linux system, many services can listen not only to a port (communicating through TCP/IP), but also to socket. Two processes can communicate through this socket file. Extended reading: socket

The two programs on the network exchange data through a two-way communication connection, one end of which is called a socket.

At least one pair of port numbers (socket) is required to establish a network communication connection. Socket is essentially a programming interface (API), which encapsulates TCP/IP. TCP/IP should also provide an interface for programmers to do network development, which is the Socket programming interface; HTTP is a car, which provides a specific form of encapsulating or displaying data; and Socket is an engine that provides the ability of network communication.

The original meaning of Socket is "hole" or "socket". As the process communication mechanism of BSD UNIX, it takes the latter meaning. Commonly known as "sockets", which are used to describe IP addresses and ports, are handles to a communication chain that can be used to communicate between different virtual machines or different computers. Hosts on Internet generally run multiple service software and provide several services at the same time. Each service opens a Socket and binds to a port, and different ports correspond to different services. Socket, as its original meaning in English, is like a porous socket. A mainframe is like a room full of sockets, each with a number, some sockets provide 220 volts AC, some provide 110 volts AC, and some provide cable TV programs. If the customer software plugs into different sockets with different numbers, you can get different services.

Vim edits my.cnf, modifies datadir Socket path # * upgrade to a newer version of MySQL. [mysqld] datadir=/data/mysqlsocket=/tmp/mysql.socksymbolic-links=0# Remove leading # and set to the amount of RAM for the most important datarpm-qf query where a file comes from installation package [root@xavi mysql] # ls / etc/my.cnf/etc/my.cnf [root@xavi mysql] # rpm-qf / etc/my.cnfmariadb-libs-5.5.52-1.el7.x86_643.2 to complete mysql configuration in the startup item You need to put the mysql.server script in the / etc/init.d/mysqld directory Edit and modify [root@localhost mysql] # ls support-files/binary-configure magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server [root@localhost mysql] # cp support-files/mysql.server / etc/init.d/mysqld3.3 modify script permissions and attributes: chmod 755 / etc/init.d/mysqld [root@localhost mysql] # chmod 755 / etc/init.d/mysqld [root@localhost mysql] # ls-l / etc/init.d/mysqld -rwxr-xr-x 1 root root 10594 February 28 11:41 / etc/init.d/mysqld3.4 Editing the copied script file vim / etc/init.d/mysqld

Add the following two sentences:

Path where the basedir=/usr/local/mysql//MySQL package is located

Datadir=/data/mysql / / define where the data is stored

If you define the path, you will report an error if you do not leave a space.

3.4 add mysql to the boot entry with chkconfig, set boot to boot and start MySQL [root @ localhost mysql] # chkconfig-- add mysqld [root@localhost mysql] # chkconfig-- list 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 3: off 4: off 5: off network 0: off 1: off 2: on 3: 4: off 5: off 6: off [root@localhost mysql] # chkconfig-- add mysqld / / add mysqld service to the list of system services [root@localhost mysql] # chkconfig mysqld on / / boot mysqld [root @ localhost mysql] # service mysqld start / / launch mysqldStarting MySQL.Logging to'/ data/mysql/zlinux.err'.. SUCCESS!

If it doesn't start, check the error log under / data/mysql/, which is usually the hostname .err.

The command to check whether mysql is started is:

[root@localhost mysql] # ps aux | grep mysqlroot 5505 0.0 11776 1568 pts/0 S 11:46 0:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- datadir=/data/mysql-- pid-file=/data/mysql/localhost.localdomain.pidmysql 5612 0.124.8 1302876 464396 pts/0 Sl 11:46 0:04 / 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/localhost.localdomain.err-- pid-file=/data/mysql/localhost.localdomain.pidroot 6527 0.0 112676 976 pts/0 S+ 12:47 0:00 grep-- color=auto mysql3.5 View listening port: netstat-lntp Is there a 3306 port [root@localhost mysql] # netstat-lntpActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0 0. 0 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 01 0.0.0.0 * LISTEN 1744/dnsmasq tcp 0 0 0.0.0.0 LISTEN 1067/cupsd 22 0.0.0.0 LISTEN 1067/cupsd 631 0.0.0.0 Tcp 0 0 127.0.0.1 LISTEN 5612/mysqld tcp6 25 0.0.0.0 LISTEN 5612/mysqld tcp6 0 0: 3306:: 111: * LISTEN 1/systemd tcp6 0 0: 22: * LISTEN 1069/sshd tcp6 0 0:: 1 LISTEN 1067/cupsd tcp6 0 0:: 1:25:: * LISTEN 15804. Start mysql,--defaults-file=/etc/my.cnf in the form of command line-- user=mysql-- datadir=/data/mysql & / / specify the file path, add commands, and use & to go to the background to run

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

[root@localhost mysql] # service mysqld stopShutting down MySQL.. SUCCESS! [root@localhost mysql] #! psps aux | grep mysqlroot 6653 0.0 112676 972 pts/0 S + 12:55 0:00 grep-- color=auto mysql [root@localhost mysql] # / usr/local/mysql/bin/mysqld_safe-- defaults-file=/etc/my.cnf-- user=mysql-- datadir=/data/mysql & [1] 6683 [root@localhost mysql] # 180228 12:58:11 mysqld_safe Logging to'/ data/mysql/localhost.localdomain.err' .180228 12:58:11 mysqld_safe Starting mysqld daemon with databases from / data/ MySQL ^ C

Ps to see if it is started

[root@localhost mysql] #! psps aux | grep mysqlroot 6683 0.0 113264 1596 pts/0 S 12:58 0:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- defaults-file=/etc/my.cnf-- user=mysql-- datadir=/data/mysqlmysql 6778 24.4 1302876 455756 pts/0 Sl 12:58 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/localhost.localdomain.err-- pid-file=/data/mysql/localhost.localdomain.pidroot 6809 0.0 112676 976 pts/0 S + 12:58 0:00 grep-- color=auto mysql

View Port

[root@localhost mysql] #! netnetstat-lntpActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 111 0.0.0. 0 LISTEN 1/systemd tcp 0 192.168.122.1 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 53 0.0 .0.0: * LISTEN 1744/dnsmasq tcp 0 0.0.0.0 LISTEN 1067/cupsd 22 0.0.0.0 LISTEN 1067/cupsd * LISTEN 1069/sshd tcp 0 0 127.0.1 Tcp 0 0 127.0.0.1 LISTEN 6778/mysqld tcp6 25 0.0.0.0 * LISTEN 1580/master tcp6 0 0: 3306:: * LISTEN 6778/mysqld tcp6 00: 111:: * LISTEN 1/systemd tcp6 0 0: 22: * LISTEN 1069/sshd tcp6 0 0:: 1 LISTEN 1067/cupsd tcp6 0 0:: 1 : 25:: * LISTEN 1580/master 4.kill command

The process must be killed with the killall command, which is safer.

The killall command finishes executing the program before killing the process.

If killall waits for a long time but does not kill it, it means that there is a large amount of data and you need to write it to disk and kill it slowly.

If the kill+PID is forcibly killed, it may result in data loss or table corruption.

4.1The mysql started by the above command line cannot be turned off by service mysqld stop, but can only be closed by killall command 4.2.The recommended method to turn on and off mysql is

Service mysqld start

Service mysqld stop

[root@localhost mysql] # killall mysqld [root@localhost mysql] # 180228 13:05:00 mysqld_safe mysqld from pid file / data/mysql/localhost.localdomain.pid made ^ C [1] + complete / usr/local/mysql/bin/mysqld_safe-defaults-file=/etc/my.cnf-user=mysql-datadir=/data/mysql [root@localhost mysql] #! psps aux | grep mysqlroot 6941 0.0 112676 976 pts/0 S+ 13:06 0:00 grep-the method of color=auto mysqlkill-9 + PID is not desirable Easy to lose data or form 4.2 mysql engine innodb and myisam pre-interview explanation?

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: 0

*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