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

LAMP Architecture introduction, MYSQL introduction, installation

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

LAMP architecture

LAMP refers to the abbreviations of Linux (operating system), Apache (httpd server), MySQL (database software), and PHP (sometimes Per or Python). It is generally used to build web servers (three roles can be on the same machine or separately. However, Apache and PHP are to be installed together.

LAMP architecture introduces how httpd, PHP and MySQL work

Description: Apache and PHP are a whole, because PHP is combined with Apache in the form of a module. But Apache can not deal with MySQL directly, it can only get the data from MySQL through PHP module. After getting the data, PHP gives the data to Apache,Apache and then to the user. The pictures, js, css and other files on the server are static files; the database files are dynamic files.

Introduction to MySQL and MariaDB

MySQL is a relational database management system in which relational databases store data in different tables instead of all data in one large warehouse, which increases speed and flexibility. (MySQL, developed by mysql ab, was acquired by sun in 2008 and sun by Oracle in 2009. )

The MariaDB database management system is a branch of MySQL and is mainly maintained by the open source community. MariaDB follows the MySQL version until version 5. 5. Version 10.0.0, which was released on November 12, 2012, will no longer follow the version number of MySQL. Version 10.0.x is based on version 5.5, plus features migrated from the MySQL5.6 version and new features developed by ourselves.

MySQL version

Community Community Edition (Community Edition, free); enterprise Enterprise Edition (paid); GA (generally available) Universal Edition, for use in production environments; DMR (development milestone release) development milestone version; RC (release candidate) release candidate version; Beta open test version; Alpha internal test version.

Install MySQL

Several common installation packages of MySQL: rpm package, source code package, binary compiler-free package

Before downloading the package, you need to check the version of the system and select the package to install according to the version of the system. You can view information about the system version by using the command uname-a. (x86664 is an operating system, i686 i586 is a 32-bit operating system)

Download the package

Download the binary uncompiled package to the / usr/local/src/ directory.

[root@localhost ~] # cd / usr/local/src

[root@localhost src] # wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

After the download is complete, there will be a compressed package mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz in the directory / usr/local/src/

Decompression package

Extract the package under the / usr/local/src/ directory

[root@localhost src] # tar-zxv-f mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

Move the extracted file and modify the file name

Move the extracted mysql-5.6.35-linux-glibc2.5-x86_64 file to the / usr/local/ directory and rename it mysql.

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

Change to the / usr/local/mysql/ directory

After changing to the / usr/local/mysql/ directory, check whether the following files and directories exist in the directory.

[root@localhost src] # cd / usr/local/mysql/

[root@localhost mysql] # ls

Bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files

Create mysql user, create / data/ directory

[root@localhost mysql] # useradd mysql

[root@localhost mysql] # mkdir / data/

Initialize mysql

[root@localhost 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::Dumpe

Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

Missing libaio.so package

Prompt that the perl module is missing and the module name is dump

Use the yum list command with grep to view the packages that need to be installed

[root@localhost mysql] # 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

Find the relevant packages and install them one by one. Then install mysql.

Note: if there are two ok during the installation process, the installation is successful. Or use the command echo $? Command, if the output is 0, the installation is successful. The result is 1, the installation fails.

Copy configuration fil

The directory of the configuration file is: / usr/local/mysql/support-files/my-default.cnf

[root@localhost mysql] # cp support-files/my-default.cnf / etc/my.cnf

The configuration file for mysql is fixed under / etc/ and is named my.cnf (if you need to specify it for another directory, otherwise the system will only look for the / etc/my.cnf file. )

You can also use the ready-made one without copying the configuration file

There is a my.cnf file in the / etc/ directory. Edit this file.

Change the following two lines to the following:

Datadir=/data/mysql

Socket=/tmp/mysql.sock

Comment out these three lines:

Log _ r _ r / etc/my.cnf.d

Startup script

The startup script directory is: / usr/local/mysql/support-files/mysql.server

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

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

Edit the / etc/init.d/mysqld file:

Basedir=/usr/local/mysql

Datadir=/data/mysql

(line 46, line 47)

Permission change:

Change the file permissions to 755 (default is 755, no need to change)

Chomd 755 / etc/init.d/mysqld

Set boot up and add the service to the list of system services:

[root@localhost mysql] # chkconfig-- add mysqld

[root@localhost mysql] # chkconfig-- list

Note: this output shows only 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 see which services are enabled for a specific target, execute

'systemctl list-dependencies [target]'.

Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off

You can also start it directly with the command:

/ etc/init.d/mysqld startservice mysqld start

[root@localhost mysql] # service mysqld start

Starting MySQL.Logging to'/ data/mysql/localhost.localdomain.err'.

. SUCCESS! # started successfully

You can use the command:

Ps aux | grep mysqld to view the process

Netstat-lntp view listening port

Stop the mysqld service

Service mysqld stop

Start on the command line (& start in the background):

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

Turn off the mysqld service

Use the killall command to shut down the service.

Kill command and killall command

Both the kill command and the killall command are used to kill processes in the system, the difference is:

1. Kill is used to kill a single process, and killall is used to kill the process tree.

2. Using the kill command will immediately end the running process. If the process is reading and writing to the disk, then the data will be lost because of the end of the process, while the killall command will wait for the data to be read and written before ending the relevant process, which is relatively safer to use.

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