编译安装LAMP之MySQL_(2)编译安装lamp三部曲之mysql-技术流ken

简介

采用yum安装lamp简单,快捷,在工作中也得到了普遍应用。但是如果我们需要某些特定模块功能,以及制定安装位置等,就需要用到编译安装了,接下来将编译安装lamp之mysql. mysql的简介网上已经有很多材料,这里就不再赘述,注重演示如何安装mysql.

系统环境及服务版本

centos7.5

服务器IP:172.20.10.7/28

mysql-5.5.33

上传mysql安装包并解压

[root@ken ~]# rz

[root@ken~]# ls

mysql-5.5.33-linux2.6-x86_64.tar.gz

[root@ken~]# tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz

移动解压包至/usr/local/目录之下

[root@ken ~]# mv mysql-5.5.33-linux2.6-x86_64 /usr/local

[root@ken ~]# cd /usr/local

[root@ken local]# ls

bin include libexec share

etc lib mysql-5.5.33-linux2.6-x86_64 src

games lib64 sbin

[root@ken local]# ln-s mysql-5.5.33-linux2.6-x86_64 mysql #对这个包做一个软连接名为mysql

创建用户mysql

[root@ken local]# groupadd -r mysql

[root@ken local]# useradd-g mysql -r -s /sbin/nologin mysql

[root@ken local]# cd mysql

[root@ken mysql]# chown-R mysql.mysql ./* #以mysql用户来运行mysql

创建数据库数据目录

[root@ken mysql]# mkdir /ken

[root@ken mysql]# chown-R mysql.mysql /ken

初始化mysql

[root@ken mysql]# cd scripts

[root@ken scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/ken --user=mysql

Installing MySQL system tables...

OK

Filling help tables...

OK

...

生成mysql的配置文件

[root@ken scripts]# cd ..

[root@ken mysql]# cd support-files/[root@ken support-files]# cp my-huge.cnf /etc/my.cnf

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

[root@ken support-files]# vim /etc/my.cnf

...33 read_buffer_size =2M34 read_rnd_buffer_size =8M35 myisam_sort_buffer_size =64M36 thread_cache_size = 8

37 query_cache_size =32M38 # Try number of CPU's*2 for thread_concurrency

39 thread_concurrency = 8

40 datadir=/ken #40行左右添加刚才创建的数据保存路径41

42 # Don't listen on a TCP/IP port at all. This can be a security enhancement,

...

生成mysql的服务管理脚本

[root@ken support-files]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@ken support-files]# chkconfig --add mysqld

[root@ken support-files]# chkconfig mysqld on

启动mysql

[root@ken support-files]# systemctl start mysqld

[root@ken support-files]# ss -tnl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN0 50 *:3306 *:*LISTEN0 128 *:22 *:*LISTEN0 100 127.0.0.1:25 *:*LISTEN0 128 :::22 :::*LISTEN0 100 ::1:25 :::*

导出二进制程序

[root@ken support-files]# vim /etc/profile.d/mysql.sh

export PATH=$PATH:/usr/local/mysql/bin

[root@ken support-files]# source /etc/profile

登录mysql

[root@ken support-files]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection idis 1Server version:5.5.33-log MySQL Community Server (GPL)

Copyright (c)2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracleis a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c'to clear the current input statement.

mysql>

登录成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值