Introduction to LAMP Architecture
linux + apache(httpd)+ mysql +php
For small websites, three (amp) services can be served on one machine, and it is best to separate them for heavily visited websites (one for httpd and php, one for mysql, connected through the network)
For example, when a user logs in to a website, he enters a username and password, which is passed to php through apache, and php to mysql, which matches the user password in mysql, and is fed back to php, and php is passed to apache, and then returned to the browser.
Introduction to MySQL and MariaDB
MySQL installation
Installation steps of binary free compilation package
- 1. Download the package
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
- 2. Unzip
tar -zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
- 3. Move the directory and change the name to mysql
mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
- 4. Enter the mysql directory
cd /usr/local/mysql
[root@glinux-01 mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
- 5. Create a mysql user Create a mysql data directory
[root@glinux-01 mysql]# useradd mysql
[root@glinux-01 mysql]# mkdir /data/
[root@glinux-01 mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
- 6. Initialize /data/mysql
[root@glinux-01 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
Error! Workaround: Install the missing package or module. But don't know the name, you can try to solve it with fuzzy search
[root@glinux-01 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
If you don't know which one is, you can install both.
run again, success
[root@glinux-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
This error can also occur. Workaround: yum install libaio* -y
[root@g_linux01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries
: libaio.so.1: cannot open shared object file: No such file or directory
- 7 Modify the configuration file vi /etc/my.cnf if there is no such file cp support-files/my-default.cnf /etc/my.cnf
8 Copy the script startup file to /etc/init.d and rename it mysqld
[root@glinux-01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
9 Modify the script vi /etc/init.d/mysqld to modify the values of basedir and datadir
basedir=/usr/local/mysql
datadir=/data/mysql
10 Set the boot to start
[root@glinux-01 mysql]# chkconfig --add mysqld
[root@glinux-01 mysql]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
11 Manually start /etc/init.d/mysqld start or service mysql start
/etc/init.d/mysqld stop shutdown
[root@glinux-01 mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/glinux-01.err'.
....... SUCCESS!
If there is no startup script to copy, you can execute this command to start mysql
/usr/local/mysql/bin/mysqld_safe --defaults=/etc/my.cnf --user=mysql --datadir=/data/mysql &
--defaults=/etc/my.cnf specifies the path where the configuration file is located
For mysql started from the command line, use killall mysqld to prevent data loss.
netstat -lntp to see if it starts