编译安装lamp三部曲之mysql-技术流ken
Posted 技术流ken
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译安装lamp三部曲之mysql-技术流ken相关的知识,希望对你有一定的参考价值。
1.简介
采用yum安装lamp简单,快捷,在工作中也得到了普遍应用。但是如果我们需要某些特定模块功能,以及制定安装位置等,就需要用到编译安装了,接下来将编译安装lamp之mysql. mysql的简介网上已经有很多材料,这里就不再赘述,注重演示如何安装mysql.
2.系统环境及服务版本
centos7.5
服务器IP:172.20.10.7/28
mysql-5.5.33
3.上传mysql安装包并解压
[[email protected] ~]# rz [[email protected] ~]# ls mysql-5.5.33-linux2.6-x86_64.tar.gz [[email protected] ~]# tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz
4.移动解压包至/usr/local/目录之下
[[email protected] ~]# mv mysql-5.5.33-linux2.6-x86_64 /usr/local
[[email protected] ~]# cd /usr/local [[email protected] local]# ls bin include libexec share etc lib mysql-5.5.33-linux2.6-x86_64 src games lib64 sbin [[email protected] local]# ln -s mysql-5.5.33-linux2.6-x86_64 mysql #对这个包做一个软连接名为mysql
5.创建用户mysql
[[email protected] local]# groupadd -r mysql [[email protected] local]# useradd -g mysql -r -s /sbin/nologin mysql [[email protected] local]# cd mysql [[email protected] mysql]# chown -R mysql.mysql ./* #以mysql用户来运行mysql
6.创建数据库数据目录
[[email protected] mysql]# mkdir /ken [[email protected] mysql]# chown -R mysql.mysql /ken
7.初始化mysql
[[email protected] mysql]# cd scripts [[email protected] scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/ken --user=mysql Installing MySQL system tables... OK Filling help tables... OK ...
8.生成mysql的配置文件
[[email protected] scripts]# cd .. [[email protected] mysql]# cd support-files/ [[email protected] support-files]# cp my-huge.cnf /etc/my.cnf cp: overwrite ‘/etc/my.cnf’? y [[email protected] support-files]# vim /etc/my.cnf ... 33 read_buffer_size = 2M 34 read_rnd_buffer_size = 8M 35 myisam_sort_buffer_size = 64M 36 thread_cache_size = 8 37 query_cache_size = 32M 38 # 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, ...
9. 生成mysql的服务管理脚本
[[email protected] support-files]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [[email protected] support-files]# chkconfig --add mysqld [[email protected] support-files]# chkconfig mysqld on
10.启动mysql
[[email protected] support-files]# systemctl start mysqld [[email protected] support-files]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *:3306 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::*
11.导出二进制程序
[[email protected] support-files]# vim /etc/profile.d/mysql.sh export PATH=$PATH:/usr/local/mysql/bin [[email protected] support-files]# source /etc/profile
12.登录mysql
[[email protected] support-files]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 1 Server version: 5.5.33-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is 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>
登录成功!
以上是关于编译安装lamp三部曲之mysql-技术流ken的主要内容,如果未能解决你的问题,请参考以下文章