msyql 编译安装

配置YUM (本地)

[[email protected] yum.repos.d]# cat CentOS-Base.repo

[base]

baseurl=file:///mnt

enabled=1

gpgcheck=0

实验环境:

[[email protected] yum.repos.d]# cat /etc/centos-release

CentOS release 6.6 (Final)

建mysql用户:

[[email protected] mysql-5.6.36]# useradd -s /sbin/nologin -M mysql

[[email protected] mysql-5.6.36]# mkdir -p /home/oldboy/tools

[[email protected] mysql-5.6.36]# tar zxvf mysql-5.6.36.tar.gz

[[email protected] mysql-5.6.36]# cd mysql-5.6.36

[[email protected]ysqlserver mysql-5.6.36]# mkdir -p /application/mysql-5.6.36/data

[[email protected]]#cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \

-DMYSQL_DATADIR=/application/mysql-5.6.36/data\

-DMYSQL_UNIX_ADDR=/application/mysql-5.6.34/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci\

-DWITH_EXTRA_CHARSETS=all\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\

-DWITH_ZLIB=bundled\

-DWITH_SSL=bundled\

-DENABLED_LOCAL_INFILE=1\

-DWITH_EMBEDDED_SERVER=1\

-DENABLE_DOWNLOADS=1\

-DWITH_DEBUG=0

[[email protected] mysql-5.6.36]# make && make install

为MySQL安装路径设置不带版本号的软链接/application/mysql,操作命令如下:

[[email protected] ~]# ln -s /application/mysql-5.6.36/ /application/mysql

[[email protected] ~]# mv /etc/my.cnf /etc/my.cnf.bak

#提示:在CentOS6.8版操作系统最小化安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。

#在启动MySQL服务时,会按照一定的顺序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",在本例中就是/application/mysql-5.6.36/my.cnf,这是新版MySQL的配置文件的默认位置!

授权:

[[email protected] application]# chown -R mysql.mysql /application/mysql/

[[email protected] application]# chmod -R 1777 /tmp

配置环境变量:

[[email protected] application]# echo ‘export PATH=/application/mysql/bin:$PATH‘>>/etc/profile

[[email protected] application]# source /etc/profile

[[email protected] application]# echo $PATH

[[email protected] application]# cd /application/mysql/scripts/

[[email protected]]#./mysql_install_db  --basedir=/application/mysql/--datadir=/application/mysql/data --user=mysql

报错:

[[email protected] scripts]#  ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql

Installing MySQL system tables...2017-05-30 12:13:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-05-30 12:13:47 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

2017-05-30 12:13:47 0 [Note] /application/mysql//bin/mysqld (mysqld 5.6.36) starting as process 3545 ...

/application/mysql//bin/mysqld: Character set ‘utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1-DWITH_ZLIB=bundled-DWITH_SSL=bundled-DENABLED_LOCAL_INFILE=1-DWITH_EMBEDDED_SERVER=1-DENABLE_DOWNLOADS=1-DWITH_DEBUG=0‘ is not a compiled character set and is not specified in the ‘/application/mysql-5.6.34/share/charsets/Index.xml‘ file

2017-05-30 12:13:47 3545 [ERROR] Aborting

2017-05-30 12:13:47 3545 [Note] Binlog end

2017-05-30 12:13:47 3545 [Note] /application/mysql//bin/mysqld: Shutdown complete

是字符集和字符冲突了,所以编译的时候要把字符和字符集选项都加上,并且要兼容!修改编译参数:

注意事项:

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

# make clean/make clean all

# rm -f CMakeCache.txt

# rm -rf /etc/my.cnf

[[email protected] mysql-5.6.36]#cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.34 \

-DMYSQL_DATADIR=/application/mysql-5.6.34/data\

-DMYSQL_UNIX_ADDR=/application/mysql-5.6.34/tmp/mysql.sock \

-DWITH_EXTRA_CHARSETS=all\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\

-DWITH_ZLIB=bundled\

-DWITH_SSL=bundled\

-DENABLED_LOCAL_INFILE=1\

-DWITH_EMBEDDED_SERVER=1\

-DENABLE_DOWNLOADS=1\

-DWITH_DEBUG=0

[[email protected] mysql-5.6.36]# make && make install

#从上文说明中可以看到数据库启动时会读取/etc/my.cnf,因此有可能会导致无法启动,避免的方法就是使用mysqld_safe启动服务时采用--defaults-file参数指定配置文件,前文已将/etc/my.cnf改名了,所以,就不需要指定参数了,这里是一个坑,读者要注意。

此步骤必须要初始化成功,否则,后面会出现登录不了数据库等各种问题。

设置MySQL启动脚本

[[email protected] scripts]# cd /home/oldboy/tools/mysql-5.6.36

[[email protected] mysql-5.6.36]# pwd

/home/oldboy/tools/mysql-5.6.36

[[email protected] mysql-5.6.36]# cp support-files/mysql.server /etc/init.d/mysqld  #<==拷贝mysql启动脚本到mysql的命令路径

[[email protected] mysql-5.6.36]# chmod 700 /etc/init.d/mysqld

[[email protected] mysql-5.6.36]#  ls -l /etc/init.d/mysqld

-rwx------. 1 root root 10677 May 30 14:18 /etc/init.d/mysqld

报错:

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

Starting MySQL.Logging to ‘/application/mysql-5.6.34/data-DMYSQL_UNIX_ADDR=/application/mysql-5.6.34/tmp/mysql.sock/mysqlserver.err‘.

The server quit without updating PID file (/application/mysql-5.6.34/data-DMYSQL_UNIX_ADDR=/application/mysql-5.6.34/tmp/mysql.sock/mysqlse[FAILED]).

解决:

[[email protected] mysql]# cp my-new.cnf /etc/my.cnf

[[email protected] mysql]# cat /etc/my.cnf

[mysqld]

# basedir = .....

datadir = /application/mysql/data

# port = .....

# server_id = .....

# socket = .....

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

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

Starting MySQL                                             [  OK  ]

[[email protected] mysql]# mysql

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

Your MySQL connection id is 1

Server version: 5.6.36 Source distribution

Copyright (c) 2000, 2017, 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> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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

4 rows in set (0.03 sec)

安装完成!

时间: 2024-10-03 16:13:47

msyql 编译安装的相关文章

LNMP编译安装之msyql安装--图文详解

LNMP编译安装之msyql安装--图文详解 1.前言 本次安装采用源码安装,主要资源包从官网下载,次要依赖则使用yum进行安装,本篇只涉及mysql的安装,msyql远程登录,不涉及mysql具体配置.该教程纯属安装,不涉及任何重要知识点,老少皆宜. 2.安装步骤 2.1.下载boost(只下载不安装) wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz 2.2.解压bosot t

编译安装msyql

环境: ubuntu18.04.2 mysql5.7.21 #创建mysql属组 groupadd mysql useradd -g mysql mysql #查看属组 tail /etc/passwd #创建mysql常用文件夹 在/usr/locle mkdir mysql mkdir boost mkdir -p /data/mysql #附属组 chown -R mysql:mysql /data/mysql chown -R mysql:mysql mysql #解压boost tar

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Mysql (二)

mysql 简介: MySQL是一个关系型数据库管理系统,关系数据库将数据保存在不同的表中,这样就增加了速度并提高了灵活性.目前其属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件.MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言. 安装环境: 系统: centos 7.0 最小化安装 软件

LAMP纯源码编译安装日志

一.LAMP构架的安装与经验技巧(源码安装好处.是便于管理,可以选定参数,可以使用新版本) 相关软件列表: # ls /soft/ | grep -E "*.gz|*.zip|*.xz|*.bz2"    apr-1.4.5.tar.gz    apr-util-1.3.12.tar.gz    autoconf-2.61.tar.gz    freetype-2.3.12.tar.gz    httpd-2.4.18.tar.bz2    jpegsrc.v6b.tar.gz    

Centos6.5上面用Shell脚本一键编译安装mysql5.5.47

操作系统及其mysql配置文件说明:Linux系统:Centos6.5 cat /etc/centos_release     查看centos版本信息 [[email protected] ~]# cat /etc/centos-release CentOS release 6.5 (Final) uname -r        #显示操作系统的发行版号 [[email protected] ~]# uname -r 2.6.32-431.el6.x86_64 uname -a      #显

LAMP 和 LNMP(LEMP) 编译安装

一.Apache2.2+PHP5.3(module) + MariaDB5.5 1.1 编译安装Apache2.2 1.2 编译安装MariaDB5.5 1.3 编译安装 PHP-5.3.29 1.4 mysql测试 二.Apache 2.4+PHP5.4(fpm)+MariaDB5.5 2.1 编译安装Apache2.4 2.2 编译安装MariaDB5.5 2.3 编译安装 PHP-5.4 2.4 mysql 测试 三.nginx1.6+ PHP5.3(fpm)+ MariaDB5.5 3.

Ubuntu安装 Alisql编译安装步骤:

github地址: https://github.com/alibaba/AliSQL 一.直接git下载保存到本地: git clone https://github.com/alibaba/AliSQL.git 二.安装依赖 apt-get install gcc build-essential cmake autoconf libncurses5-dev perl bison 说明: centos里面 build-essental换成 gcc-c++, libncurses5-dev换成n

mysql5.1的编译安装 ----针对第一次安装mysql的

由于是第一次安装,不能确定你是否有安装编译和mysql所要依赖的插件,使用我是当做你最原始的安装环境.  1.安装mysql5.1的依赖包 yum install -y gcc gcc-c++ autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool* openssl* 2.上传mysql的安装包,可以在官方网站下载,注意是要下载源代码. 3.上传到root的根目录 4.开始编译安装mysql5.1 mkdir -p

Cent OS 6.5 Mysql-5.6.19 编译安装

今天来写写MySQL 5.6.19的编译安装,现在5.6版本的安装比较发杂一点了,不扯了开始吧! 安装环境 OS:Cent OS 6.5 软件:Mysql 5.6.19 下载软件 http://mirrors.sohu.com/mysql/MySQL-5.6/Mysql-5.6.19.tar.gz 安装前环境配置    #yum install -y lrzsz (这个软件可以上传文件)    #rz                  (找到你刚才下载的mysql)    #yum groupi