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

Summary of Linux Learning (30) mysql installation of lamp

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

Share

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

An introduction to lamp architecture

Lamp is the abbreviation of linux apache mysql php, which is the whole set of server environment. For the website developed by php, the pages or data we visit are likely to be provided by this environment. For ordinary netizens, we do not pay attention to the content of the website we visit, which is actually divided into two categories, one is the static data represented by pictures, and the other is the dynamic data stored in the database, such as the user name and password of our login blog. We decompose the principle of each part according to the following figure, linux of course refers to our linux operating system centos,ubuntu and so on. Apache we all know that he is the name of a foundation, and its essence is a web server named httpd. Mysql is a database, which is used to store dynamic data, and what he is really dealing with is an application called php. In the lamp architecture, he exists as a module of httpd. The static file requested by the user is directly stored on the server, and the dynamic data is stored in the database, which is transferred to web after the php call. The database can be installed on other servers separately and connected through the network.

Two mysql installation

Let's take a look at the installation of mysql in detail.

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

Here we use the binary compiler-free package to install it. Compared with the source package, it does not have to solve the error of compiling missing libraries, and the installation is simpler.

Single, because he is compiled in the linux system, relative to rpm, he can specify a directory to facilitate package management.

Cd / usr/local/src to this directory, and put the downloaded application packages here.

Wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

Download a mysql package. If the link fails, you can find another mirror source.

Tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

1 packet renaming

Mv mysql-5.6.35-linux-glibc2.5-x86_64 / usr/local/mysql

Cd / usr/local/mysql

2 create a user and data storage directory

Useradd mysql mkdir / data/

3 initialization

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

We found that the Dumper package under the perl module was missing, so we tried to find the following

Yum list | grep perl | grep-I dumper / /-I ignore case

We can try to install these two packages to see if we can solve the above problem, or we can install both and initialize them.

After our yum installed the first package above, we initialized it again and found that there was another problem. It was really a bad start, but don't be afraid. We checked the solution on the Internet: lack of libaio library files, put a big move directly, yum install-y libaio* later I found that you can directly

Yum povides libaio.so.1 looks for this library file, after all, this fuzzy matching installation is not practical.

After installation, echo $? The result is zero. That's great.

Cp support-files/my-default.cnf / etc/my.cnf

Copy the configuration file template and edit it, and we find that there is already a my.cnf under / etc/, so you can edit the my-default.cnf file directly without the above my-default.cnf file.

4 Editing the profile

Vim / etc/my.cnf

We define datadir and socket and comment out the rest.

5 define startup script

Cp support-files/mysql.server / etc/init.d/mysqld

Vim / etc/init.d/mysqld

Copy the startup file and edit

Define basedir and datadir

/ etc/init.d/mysqld start

When sucess appears, it means that the startup is successful. You can ps aux | grep mysqld to view the process.

6 to achieve boot boot, you can

Chkconfig-- add mysqld / / join the list of system services chkconfig mysqld on

Note:

I always thought that mysql would load / etc/my.cnf the configuration file first, but later I found that this was not the case. According to my current understanding, the configuration file under / etc should belong to the application installed directly by yum. However, we use the installation method of binary compiler-free package. So why is there no problem with our configuration above, because the load is defined in the startup script, and in the support-files/mysql.server file, the my.cnf configuration file under $basedir is defined to load first. If there is no definition, go to / etc/my.cnf. The / etc/my.cnf we just configured takes effect because $basedir / my.cnf is not defined and is in the annotated state.

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