LAMP架构MYSQL安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP架构MYSQL安装相关的知识,希望对你有一定的参考价值。
LAMP架构
1.lamp包含什么
1.首先下载软件包
[[email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
--2018-02-26 21:12:00-- http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
正在解析主机 mirrors.sohu.com (mirrors.sohu.com)... 221.236.12.140
正在连接 mirrors.sohu.com (mirrors.sohu.com)|221.236.12.140|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:316320366 (302M) [application/octet-stream]
正在保存至: “mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz”
100%[====================================>] 316,320,366 525KB/s 用时 11m 2s
2018-02-26 21:23:02 (467 KB/s) - 已保存 “mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz” [316320366/316320366])
2.解压缩
tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
3.移动目录并改名
[[email protected] src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
4.进入mysql目录
[[email protected] src]# cd /usr/local/mysql/
[[email protected] mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
5.创建用户,目录并初始化
[[email protected] mysql]# useradd mysql
[[email protected] mysql]# mkdir /data/
[[email protected] mysql]# ls /data/
[[email protected] 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
6.有报错,需要安装perl包:
[[email protected] mysql]# yum install -y perl-Data-Dumper
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 perl-Data-Dumper.x86_64.0.2.145-3.el7 将被 安装
--> 解决依赖关系完成
7.完成后继续执行,有报错:
[[email protected] 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
需要安装
[[email protected] mysql]# yum install -y libaio-devel
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 libaio-devel.x86_64.0.0.3.109-13.el7 将被 安装
--> 正在处理依赖关系 libaio(x86-64) = 0.3.109-13.el7,它被软件包 libaio-devel-0.3.109-13.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libaio.x86_64.0.0.3.109-13.el7 将被 安装
8.初始化:
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables...2018-02-26 22:25:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-02-26 22:25:59 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-02-26 22:25:59 0 [Note] ./bin/mysqld (mysqld 5.6.36) starting as process 1622 ...
2018-02-26 22:25:59 1622 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-02-26 22:25:59 1622 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-26 22:25:59 1622 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-26 22:25:59 1622 [Note] InnoDB: Memory barrier is not used
2018-02-26 22:25:59 1622 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-02-26 22:25:59 1622 [Note] InnoDB: Using Linux native AIO
9.执行完成后马上执行
[[email protected] mysql]# echo $?
0
检验上一条是否正确,0为正确
10.复制配置文件,或更改自带文件
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf^C
[[email protected] mysql]# ls /etc/my.cnf
/etc/my.cnf
[[email protected] mysql]# rpm -qf /etc/my.cnf
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] mysql]# vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-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 http://fedoraproject.org/wiki/Systemd
[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
11.复制启动脚本
[[email protected] mysql]# ls support-files/
binary-configure my-default.cnf mysql-log-rotate
magic mysqld_multi.server mysql.server
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
12.更改启动脚本:
[[email protected] mysql]# vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql
13.设置开机启动
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] 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:关
14.立刻启动程序:
[[email protected] mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/weixing01.err‘.
. SUCCESS!
15.采用命令行方式启动:
[[email protected] mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &
[1] 2101
[[email protected] mysql]# 180226 22:44:15 mysqld_safe Logging to ‘/data/mysql/weixing01.err‘.
180226 22:44:15 mysqld_safe Starting mysqld daemon with databases from /data/mysql
16.用killall杀死程序,比kill保险,不会在磁盘读写时损坏数据
[[email protected] mysql]# killall mysqld
[[email protected] mysql]# 180226 22:47:13 mysqld_safe mysqld from pid file /data/mysql/weixing01.pid ended
[1]+ 完成 /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql
[[email protected] mysql]# ps aux |grep mysql
root 2398 0.0 0.0 112676 984 pts/0 R+ 22:47 0:00 grep --color=auto mysql
以上是关于LAMP架构MYSQL安装的主要内容,如果未能解决你的问题,请参考以下文章
LAMP架构(LAMP介绍,mysql/mariaDB介绍,Mysql安装)
LAMP架构(LAMP介绍,mysql/mariaDB介绍,Mysql安装)