1、LAMP = linux + apache + mysql(mariadb/mongodb) + php
2、mysql 安装:
先下载安装包:
wget -c http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
解压: tar -xvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
移动到: mv ./mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql56
cd /usr/local/mysql56
创建用户:
useradd -M mysql -s /sbin/nologin
./scripts/mysql_install_db --user=mysql --datadir=./data/mysql
若报这个错:
FATAL ERROR: please install the followingPerl modules before executing ./scripts/mysql_install_db:
Data::Dumper
需要安装:
[root@one_year mysql56]#yum list |grep 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
[root@one_year mysql56]# yum install perl-Data-Dumper.x86_64 -y
安装perl模块:yum install perl-Data-Dumper.x86_64 -y
若报错:
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@one_year bin]#yum list | grep libaio
libaio.i686 0.3.109-13.el7 base
libaio.x86_64 0.3.109-13.el7 base
libaio-devel.i686 0.3.109-13.el7 base
libaio-devel.x86_64 0.3.109-13.el7 base
[root@one_year bin]# yum install^C
[root@one_year bin]# yum install libaio.x86_64 libaio-devel.x86_64 -y
再进行安装:
./scripts/mysql_install_db --user=mysql --datadir=./data/mysql
然后,再复制配制文件:
cp support-files/my-default.cnf /etc/my.cnf
修改:/etc/my.cnf
再复制:cp support-files/mysql.server /etc/init.d/mysqld
再修改vim /etc/init.d/mysqld
直接用命令启的方式:
/usr/local/mysql56/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/usr/local/mysql56/data/mysql &
mysql服务的开启和关闭:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
3、mariaDB的安装:
下载安装包:
wget -c https://downloads.mariadb.com/MariaDB/mariadb-10.3.6/bintar-linux-glibc_214-x86_64/mariadb-10.3.6-linux-glibc_214-x86_64.tar.gz
解压:
tar -xvf mariadb-10.3.6-linux-glibc_214-x86_64.tar.gz
移动并重命名:
mv ./mariadb-10.3.6-linux-glibc_214-x86_64 /usr/local/mariadb1036
进入该目录:
cd /usr/local/mariadb1036/
创建一个用户:
useradd -M mariadb -s /sbin/nologin
安装:
./scripts/mysql_install_db --user=mariadb --basedir=/usr/local/mariadb1036/ --datadir=./data/mysql/
复制: cp ./support-files/mysql.server /etc/init.d/mariadbd
编辑:/etc/init.d/mariadbd
指定相关路径:
basedir=/usr/local/mariadb1036/
datadir=/data/mysql/
conf=/usr/local/mariadb1036/my.cnf
$bindir/mysqld_safe --user="mariadb" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
wait_for_ready; return_value=$?
在启动的时候,用这个用户,不然后,无法启动,因为在安装的时候用的是这个用户
进行配制文件的配制:
/etc/my.cnf
这个根据自己的实际情况配制。
配制socket路径:
socket = /tmp/mysqld.sock
[client]
socket = /tmp/mysqld.sock
安装成功后,启动就可以了