本文共 4165 字,大约阅读时间需要 13 分钟。
LAMP指的Linux(操作系统)、Apache(httpd 服务器),MySQL(数据库软件) 和PHP(有时也是指Perl或Python) 的缩写,一般用来建立web 服务器(三个角色可以在一台机器也可以分开,但是Apache和PHP要安装在一起) 。
Apache、PHP、MySQL工作模式
说明: 服务器上的图片、js、css等文件属于静态文件;数据库文件是动态文件。
MySQL 是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护。MariaDB直到5.5版本,均依照MySQL的版本。从2012年11月12日起发布的10.0.0版开始,不再依照MySQL的版号。10.0.x版以5.5版为基础,加上移植自MySQL5.6版的功能和自行开发的新功能。
MySQL版本:
community 社区版;enterprise 企业版;GA(generally available) 通用版,在生产环境中使用;DMR(development milestone release) 开发里程碑版本;RC(release candidate) 发行候选版本;Beta 开放测试版本;Alpha 内部测试版本。uname命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)。
语法: uname [options]
Options: -a:=all,显示全部信息-m:=machine,显示电脑类型-n:显示在网络上的主机名-r:显示操作系统的发行编号-s:显示操作系统名称-v:显示操作系统版本-p:显示处理器类型或“unknown”-i:输出硬件平台-o:输出操作系统名称rpm包、源码包、二进制免编译包。
MySQL-5.6-64位二进制免编译包镜像下载地址:
准备工作
切换至/usr/local/src/目录
[root@centos-01 ~]# cd /usr/local/src/
下载MySQL二进制免编译包
[root@centos-01 ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
解压包
[root@centos-01 ~]# tar zxvf /usr/local/src/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
将安装文件移动到/usr/local/目录
[root@centos-01 ~]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
切换至mysql目录下
[root@centos-01 ]# cd /usr/local/mysql/
[root@centos-01 mysql]# lsbin data include man README share support-filesCOPYING docs lib mysql-test scripts sql-bench创建MySQL用户
[root@centos-01 mysql]# useradd mysql
创建数据库目录
[root@centos-01 mysql]# mkdir /data/
初始化
[root@centos-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
错误提示1:
[root@centos-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根据提示搜索相应的安装包并进行安装:[root@centos-01 mysql]# yum install -y perl-Data-Dumper
错误提示2:
[root@centos-01 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根据提示信息安装有关的库文件: [root@centos-01 mysql]# yum -y install libaio* libaio-dev*
完成上述操作后先检测"./scripts"命令是否正确执行:
[root@centos-01 mysql]# echo $? 0
拷贝配置文件到/etc/my.cnf
[root@centos-01 mysql]# cp support-files/my-default.cnf /etc/my.cnf
编辑MySQL的系统配置文件/etc/my.cnf
将模板中内容改成如下格式:[root@centos-01 mysql]# vim /etc/my.cnf[mysqld]datadir=/data/mysqlsocket=/tmp/mysql.sock#Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0#Settings user and group are ignored when systemd is used.#If you need to run mysqld under a different user or group,#customize your systemd unit file for mariadb according to the#instructions in[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log#pid-file=/var/run/mariadb/mariadb.pid# include all files from the config directory # #!includedir /etc/my.cnf.d
修改启动脚本
将启动脚本添加到系统配置文件/etc/init.d/中:
[root@centos-01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld修改配置文件:
[root@centos-01 mysql]# vim /etc/init.d/mysqld……basedir=/usr/local/mysqldatadir=/data/mysql……更改配置文件权限(默认情况是755):
[root@centos-01 mysql]# chmod 755 /etc/init.d/mysqld此步骤可以省略!启动MySQL服务
将MySQL服务添加到开机启动服务中:[root@centos-01 mysql]# chkconfig --add mysqld[root@centos-01 mysql]# chkconfig --listmysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关network 0:关 1:关 2:开 3:开 4:开 5:开 6:关启动MySQL服务:方法1:[root@centos-01 mysql]# /etc/init.d/mysqld start
方法2:
[root@centos-01 mysql]# service mysqld startStarting MySQL.Logging to '/data/mysql/centos-01.err'... SUCCESS!异常启动MySQL服务:
情景:MySQL启动脚本无法添加到/etc/init.d/中或者没有启动脚本,可以使用如下方法启动:[root@centos-01 mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &
kill命令和killall命令都是用来杀死系统中的进程,区别是:
kill用来杀死单个进程,killall用来杀死进程树
使用kill命令会立刻结束正在运行中的进程,如果该进程正在进行磁盘的读写,那么数据会因为进程的结束而丢失,而killall命令会等待该数据读写完毕后再将相关进程结束,相对来说使用起来更加安全。转载于:https://blog.51cto.com/13242922/2073353