LAMP架构介绍MySQL,MariaDB介绍MySQL安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP架构介绍MySQL,MariaDB介绍MySQL安装相关的知识,希望对你有一定的参考价值。

LAMP架构介绍

LAMP指的L(linux)、A(Apache)、M(mysql)、P(php);apache+php需要在一台主机,mysql可以分开也可以在同一台主机上运行。

工作模式如下:

技术分享

静态文件:图片、文档,不用通过加载mysql去取数据

动态文件:js等通过php模块调用mysql,再通过apache展示来实现的动态资源


MySQL,MariaDB介绍

mysql:关系型数据库,由sun公司研发,后被oracle公司收购;

其版本:

community 社区版;enterprise 企业版;GA(generally available) 通用版,在生产环境中使用;DMR(development milestone release) 开发里程碑版本;RC(release candidate) 发行候选版本;Beta 公测版本;Alpha 内部测试版本。

MariaDB:和mysql基本一致,是mysql的一个分支。


MySQL安装

常用的安装包:

rpm包(rpm -ivh 安装)

源码包(源代码编译安装,耗时比较久,一般也得20多分钟)

二进制免编译包(已经编译好的,拿来就可以直接使用,简单快速安装)


1、下载安装包(二进制免编译包):

[[email protected] package]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

2、解压

[[email protected] package]# tar xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz 

3、[[email protected] package]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql

4、创建mysql、data目录

[[email protected] mysql]# useradd mysql

[[email protected] mysql]# mkdir /data/ 

5、安装相应的软件包

[[email protected] mysql]# yum install -y perl-Data-Dumper libaio* libaio-dev*

6、初始化

[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

7、验证是否正确

[[email protected] mysql]# echo $?

0

8、拷贝配置文件到/etc

[[email protected] mysql]# cp support-files/my-default.cnf  /etc/my.cnf

cp: overwrite ‘/etc/my.cnf’? y

9、新增datadir、socket:

[[email protected] mysql]# cat /etc/my.cnf

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.


[mysqld]

datadir=/data/mysql

socket=/tmp/mysql.sock

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M


10、启动脚本:

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld 

[[email protected] mysql]# vi /etc/init.d/mysqld 

basedir=/usr/local/mysql

datadir=/data/mysql


11、[[email protected] mysql]# chmod 755 /etc/init.d/mysqld

12、

[[email protected] mysql]# chkconfig --add mysqld

[[email protected] mysql]# chkconfig --list| grep mysqld


Note: This output shows SysV services only and does not include native

      systemd services. SysV configuration data might be overridden by native

      systemd configuration.


      If you want to list systemd services use ‘systemctl list-unit-files‘.

      To see services enabled on particular target use

      ‘systemctl list-dependencies [target]‘.


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

13、启动

[[email protected] mysql]# /etc/init.d/mysqld start

14、[[email protected] mysql]# netstat -nutlp| grep mysqld

tcp6       0      0 :::3306                 :::*                    LISTEN      18112/mysqld 

14、错误信息:

[[email protected] ~]# killall

-bash: killall: command not found


解决:[[email protected] ~]# yum install psmisc -y

15、[[email protected] ~]# killall mysqld

16、没有启动脚本时,如下启动:

[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &

17、[[email protected] ~]# ps aux|grep mysql


本文出自 “探索发现新事物” 博客,请务必保留此出处http://shenj.blog.51cto.com/5802843/1979858

以上是关于LAMP架构介绍MySQL,MariaDB介绍MySQL安装的主要内容,如果未能解决你的问题,请参考以下文章

LAMP架构(LAMP介绍,mysql/mariaDB介绍,Mysql安装)

LAMP架构(LAMP介绍,mysql/mariaDB介绍,Mysql安装)

LAMP架构介绍,MYSQL和MariaDB介绍,MYSQL安装

LAMP架构介绍,MYSQL和MariaDB介绍,MYSQL安装

LAMP架构介绍MySQL,MariaDB介绍MySQL安装

LAMP架构介绍MySQL和MariaDB介绍MySQL安装