lnmp-----mysql安装----myql二进制安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lnmp-----mysql安装----myql二进制安装相关的知识,希望对你有一定的参考价值。

mysql 二进制安装,仅需要解压就可以,不需要  cmake/configure,make,make install

 

[[email protected] tools]# pwd
/home/yang/tools

[[email protected] tools]# groupadd mysql
[[email protected] tools]# useradd -s /sbin/nologin -g mysql -M mysql

1.采用二进制方式安装MySQL

[[email protected] tools]# tar -xf mysql-5.5.54-linux2.6-x86_64.tar.gz 

[[email protected] tools]# mv mysql-5.5.54-linux2.6-x86_64 /application/mysql-5.5.54   #移动并改名目录

2.创建软链接

[[email protected] tools]# ln -s /application/mysql-5.5.54/ /application/mysql  #设置软连接

[[email protected] tools]# ls -l /application/      #查看mysql软链接
total 8 
lrwxrwxrwx. 1 root root 26 Mar 2 11:58 mysql -> /application/mysql-5.5.54/
drwxr-xr-x. 13 root root 4096 Mar 2 11:53 mysql-5.5.54

当前lnmp一体化环境时候,mysql数据库和nginx在一台服务器上,如果mysql与nginx不在一台服务器上时,nginx服务器上的mysql数据库软件包只需要解压移动到/application目录,改名为mysql就可以,不要进行后面测初始化设置。

在非一体化的LNMP环境(及mysql与nginx不在一台服务器上),编译php环境时,也需要mysql数据库环境,但是高版本的PHP,例如5.3版本以上,内置了PHP需要的mysql程序,因此,对于此类版本就不需要再nginx服务器上安装mysql软件了,值需要再编译PHP时指定相关的参数即可,这个PHP的编译的参数为 --with-mysql=mysqlnd,标示PHP程序在编译时会调用内置的mysql的库

3.初始化MySQL配置文件my.cnf

[[email protected] tools]# cd /application/mysql
[[email protected] mysql]# ls -l support-files/*.cnf
-rw-r--r--. 1 7161 31415 4691 Nov 29 00:10 support-files/my-huge.cnf
-rw-r--r--. 1 7161 31415 19759 Nov 29 00:10 support-files/my-innodb-heavy-4G.cnf
-rw-r--r--. 1 7161 31415 4665 Nov 29 00:10 support-files/my-large.cnf
-rw-r--r--. 1 7161 31415 4676 Nov 29 00:10 support-files/my-medium.cnf
-rw-r--r--. 1 7161 31415 2840 Nov 29 00:10 support-files/my-small.cnf

[[email protected] mysql]# /bin/cp support-files/my-small.cnf /etc/my.cnf  #因为是测试环境,所以选择参数配置小的my-small.cnf配置模板,如果是生产环境可以根据硬件选择更高级的配置文件

my-medium.cnf ==>my-small.cnf==>my-large.cnf==>my-huge.cnf==>my-innodb-heavy-4G.cnf   #对硬件的要求从低到高依次为

 

[[email protected] mysql]# yum install libaio
[[email protected] mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql #初始化数据库

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld #拷贝MYSQL启动脚本到MySQL命令行

[[email protected] mysql]# sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[[email protected] mysql]# netstat -tulnp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 9020/mysqld

 

设置MySQL开机自启动

[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig mysqld on
[[email protected] mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off




















以上是关于lnmp-----mysql安装----myql二进制安装的主要内容,如果未能解决你的问题,请参考以下文章

coetos7 安装lnmp mysql8.0

LAMP+LNMP MySQL/Mariadb概述与安装实践

LAMP+LNMP MySQL/Mariadb概述与安装实践

linux上docker简单部署lnmp+redis

Mysql安装

phpStorm怎么解决502 bad gateway