Linux 源码安装mysql

源码安装mysql

tar zxf mysql-boost-5.7.11.tar.gz

rpm -ivh cmake-2.8.12.2-4.el6.x86_64.rpm

yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y

cd mysql-5.7.11/

yum install gcc-c++ ncurses-devel bison -y

检测

[[email protected]]#

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql #安装目录

-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data#数据库存放目录

-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock #Unix socket文件路径-DWITH_MYISAM_STORAGE_ENGINE=1 #安装 myisam 存储引擎-DWITH_INNOBASE_STORAGE_ENGINE=1# 安装 innodb 存储引擎-DWITH_PARTITION_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1

#安装数据库分区

-DDEFAULT_CHARSET=utf8 #使用 utf8 字符

-DDEFAULT_COLLATION=utf8_general_ci

-DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/

make && make install##这个编译过程时间需要一个小时左右

##在make install 阶段如果出现很多红色的字体,并且界面卡住了,可以直接ctrl +C中断安装状态,重新执行make install即可

重新编译时,需要清除旧的对象文件和缓存信息

make clean

rm -f CmakeCache.txt

然后再继续camak,make && make install

cd /usr/local/lnmp/mysql/bin

[[email protected] bin]# vim ~/.bash_profile

10 PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin#这样就能自动补齐

[[email protected] bin]# source ~/.bash_profile#刷新,立即生效

[[email protected] bin]# cd ..

[[email protected] mysql]# cd support-files/

[[email protected] support-files]# rpm -e `rpm -qa | grep mysql` --nodeps

warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave

说明:由于本机之前安装过mysql 所以源码安装的时候需要清除环境影响

这里还不能直接yum remove。yum remove会把软件的依赖性一起删除,并且会导致postfix等服务启动出现故障。

[[email protected] support-files]# yum install mysql-libs -y

[[email protected] support-files]# yum check

[[email protected] support-files]# /etc/init.d/postfix restart#检测是否排除上文提及的问题

关闭 postfix:                                             [确定]

启动 postfix:                                             [确定]

[[email protected] support-files]# rpm -qa | grep mysql

mysql-libs-5.1.71-1.el6.x86_64

[[email protected] support-files]# cat /etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

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

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

cp:是否覆盖"/etc/my.cnf"? y

[[email protected] support-files]# file mysql.server

mysql.server: POSIX shell script text executable

[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld#复制启动脚本

[[email protected] mysql]# cd /var/lib/

[[email protected] lib]# /etc/init.d/mysqld status

ERROR! MySQL is not running

[[email protected] lib]# cd /usr/local/lnmp/mysql/

[[email protected] mysql]# ls

bin  COPYING  docs  include  lib  man  mysql-test  README  share  support-files

[[email protected] mysql]# ll

总用量 56

drwxr-xr-x  2 root root  4096 3月  22 23:38 bin

-rw-r--r--  1 root root 17987 2月   2 2016 COPYING

drwxr-xr-x  2 root root  4096 3月  22 23:37 docs

drwxr-xr-x  3 root root  4096 3月  22 23:37 include

drwxr-xr-x  4 root root  4096 3月  22 23:38 lib

drwxr-xr-x  4 root root  4096 3月  22 23:37 man

drwxr-xr-x 10 root root  4096 3月  22 23:38 mysql-test

-rw-r--r--  1 root root  2478 2月   2 2016 README

drwxr-xr-x 28 root root  4096 3月  22 23:38 share

drwxr-xr-x  2 root root  4096 3月  22 23:38 support-files

[[email protected] mysql]# grep mysql /etc/passwd#查看mysql这个用户信息

mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash

[[email protected] mysql]# grep mysql /etc/shadow

mysql:!!:17218::::::

[[email protected] mysql]# chown mysql.mysql . -R#将当前目录下所有文件的所有人所有组都设置成mysql -R表示第归

[[email protected] mysql]# which mysql

/usr/local/lnmp/mysql/bin/mysql

[[email protected] mysql]# mysql_install_db --user=mysql --basedir=/usr/local/lnmp/mysql/ --datadir=/usr/local/lnmp/mysql/data

2017-03-23 00:24:03 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

##mysql_install_db这个命令是不被认同的,让我们用mysqld --initialize这个命令

2017-03-23 00:24:42 [WARNING] The bootstrap log isn‘t empty:

2017-03-23 00:24:42 [WARNING] 2017-03-22T16:24:03.786590Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2017-03-22T16:24:03.792333Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2017-03-22T16:24:03.792343Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

[[email protected] mysql]# pwd

/usr/local/lnmp/mysql

[[email protected] mysql]# cd data/

[[email protected] data]# rm -fr *

[[email protected] data]# cd ..

[[email protected] mysql]# mysqld --initialize --user=mysql --basedir=/usr/local/lnmp/mysql/ --datadir=/usr/local/lnmp/mysql/data

当最后输出如下:

2017-03-22T16:27:58.726507Z 1 [Note] A temporary password is generated for [email protected]t: W_Ad1p4htKk-##加粗字体是mysql的初始登陆密码

[[email protected] mysql]# chown root.root . -R

[[email protected] mysql]# chown mysql data -R

[[email protected] mysql]# cd data/

[[email protected] data]# ls

auto.cnf        ibdata1      ib_logfile1  performance_schema

ib_buffer_pool  ib_logfile0  mysql        sys

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

Starting MySQL. SUCCESS!

[[email protected] data]# ls

auto.cnf        ib_logfile1      mysql.sock               server2.example.com.pid

ib_buffer_pool  ibtmp1           mysql.sock.lock          sys

ibdata1         mysql            performance_schema

ib_logfile0     mysqld_safe.pid  server2.example.com.err

报错信息会记录再server2.example.com.err文件中

[[email protected] data]# mysql -p

Enter password:

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

Your MySQL connection id is 3

Server version: 5.7.11

Copyright (c) 2000, 2016, 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> alter user [email protected] identified by ‘lyitx+110‘;##重新设置密码

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

 

mysql> exit

Bye

这样mysql就安装成功了!!!

时间: 2024-10-12 08:18:27

Linux 源码安装mysql的相关文章

linux 源码安装mysql 5.5

今天在ubuntu和CentOS下,用源码反复安装了许多次mysql,趁还没忘记,赶紧记下来... 在ubuntu和CentOS下安装过程倒是没什么差别. 0.下载源码,传到服务器上 1.准备cmake和libncurse ubuntu 下用 apt-get install cmake 和apt-get install libncurse安装 CentOS下用yum -y install ncurses-devel 和yum -y install cmake安装.某些版本要用yum -y ins

Linux源码安装MySQL

MySQL的安装方式有很多,最简单最适用的就是二进制方法安装. 1.创建数据目录: mkdir /data/{server,soft} -p 2.解压软件并制定解压路径: tar -xvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz -C /data/server 3.名字过长,创建软连接: ln -s mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz mysql-5.6.35 4.创建专用用户: useradd -s /

linux上源码安装MySQL详解

最近需要使用MySQL Fabric,这货是MySQL5.6.10之后才出现的utility.手头机器装的是MySQL5.1,所以需要先把旧版MySQL升级成5.6版本.之前没有玩过MySQL,所以这次稍微费了点事.在此,把过程记录下来,希望能给有需求的人提供一点帮助.下面我们就正式开始. 1. 删除老版本MySQL 其实删除老版MySQL是一件很简单的事,但是开始时候由于担心各个包的依赖会导致各种问题,亦步亦趋来得很慢.其实只需要做到这么几步就可以了: 1.1 查看已安装的mysql版本并删除

Linux平台下源码安装mysql多实例数据库

Linux平台下源码安装mysql多实例数据库[[email protected] ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6191/mysqld [[email protected] ~]# ss -tlunp | grep 330tcp LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=6191,fd=10)) [[email protected] ~]# syst

CentOS 7下源码安装MySQL 5.7

网上说linux安装mysql服务分两种安装方法: ①源码安装,优点是安装包比较小,只有几十M左右,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: ②使用官方编译好的二进制文件安装,优点是安装速度快,安装步骤简单,缺点是安装包很大,300M左右(5.7版本的是600M左右), 对于第二种方法,我搞了一天,无果,到某个环节实在是无法走通,老大那边也不让搞了,隔了几天老大又吩咐我在生产服务器上安装mysql,这次我就按照第一种方法源码安装方式 下载源码安装包 http://dev.my

源码安装mysql,及主从同步

源码安装mysql [可选] 如果用源码安装cmake软件: cd /home/oldboy/tools/ tar xf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure #CMake has bootstrapped. Now run gmake. gmake gmake install cd ../ 依赖包安装(这里直接可以用yum安装cmake) # yum install cmake gcc gcc-c++ gcc-g77 autoconf au

mysql-5.5 for linux源码安装

mysql-5.5 for linux源码安装 1.使用Yum安装依赖软件包 # yum install -y gcc gcc-c++ gcc-g77 autoconf automake bison zlib* fiex* \ libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* 2.安装cmake # yum install -y cmake 3.解压缩并编译安装MySQL源码包 # tar xzvf mysql-5.5.27.tar.gz

CentOS 6.4 源码安装MySQL 5.6

1.安装前准备工作 1.1 必备的包 gcc/g++ :MySQL 5.6开始,需要使用g++进行编译.cmake :MySQL 5.5开始,使用cmake进行工程管理,cmake需要2.8以上版本.bison :MySQL语法解析器需要使用bison进行编译.ncurses-devel :用于终端操作的开发包. 1.2 MySQL编译参数 CMAKE_BUILD_TYPE 编译的版本类型:RelWithDebInfo和Debug,不同之处是RelWithDebInfo会进行优化.CMAKE_I

CentOS7 下源码安装MySQL 8.0.11

CentOS7 下源码安装MySQL 8.0.11 系统环境:CentOS7, 内核:Linux 3.10.0-862.el7.x86_64 如果有旧版本的MySQL,先卸载,用下面命令来查询出系统有哪些相关的MySQL包. rpm -qa | grep mysql 如果上述命令查询出有相关的MySQL包,就卸载 rpm -e 包名 卸载MariaDB包 yum remove mariadb-libs.x86_64 从MySQL官网下载源码包,并将该文件拷贝到系统中. https://dev.m