CentOS6.6源码安装MySQL

安装编译源码所需工具和库(重要)

yum install gcc gcc-c++ ncurses-devel perl cmake

新建用户组及用户

groupadd mysql
useradd -r -g mysql mysql  

新建安装目录

mkdir -p /usr/local/mysql 

mkdir -p /usr/local/mysql/data

下载MySQL源码

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz

解压缩命令

tar -zxvf mysql-5.6.26.tar.gz

使用cmake设置源码编译配置脚本

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1

ps: -DWITH_FEDERATED_STORAGE_ENGINE=1 跨服务器查询会用到,  如果编译的时候未指定FEDERATED引擎, 后期通过INSTALL PLUGIN的方式安装会出现问题

SQL>install plugin federated soname ‘ha_federated.so‘;
ERROR 1126 (HY000): Can‘t open shared library ‘/usr/local/mysql/lib/mysql/plugin/ha_federated.so‘ (errno: 2 undefined symbol: dynstr_append_mem)

这是MySQL的bug, 只能通过编译源码重新安装解决, 项目难免会涉及到跨数据库查询, 所以此处在编译的时候指定FEDERATED引擎

编译源码

make

安装

make install

修改安装目录及数据库目录用户组及所有者

cd /usr/local/mysql
chown -R mysql:mysql .

cd /usr/local/mysql/data
chown -R mysql:mysql .

初始化MySQL数据库

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/

复制配置文件

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf 

修改默认字符集, 在my.cnf  文件 [mysqld] 标签下添加

character-set-server=utf8

创建mysqld系统服务

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

启动mysqld服务(CentOS 6 的命令)

service mysqld start

添加mysql系统命令, 编辑/etc/profile  , 追加以下内容

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

使配置立即生效

source /etc/profile

进入控制台

[[email protected] etc]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26 Source distribution

Copyright (c) 2000, 2015, 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>

设置root用户密码和远程访问权限

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password(‘123456‘) where user=‘root‘;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option;
Query OK, 0 rows affected (0.00 sec)

finished

补充:

查看数据库是否支持FEDERATED引擎

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

解决方法:

编辑 my.cnf 文件追加

federated 

仅此一条, 重启mysqld服务, 再看一下

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| FEDERATED          | YES     | Federated MySQL storage engine                                 | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)
时间: 2024-10-17 08:25:16

CentOS6.6源码安装MySQL的相关文章

CentOS6.5源码安装多个MySQL实例及复制搭建

多实例安装本节是在CentOS6.5源码安装MySQL5.6.35的基础上,在同一台机器增加一个MySQL实例.参考Centos中安装多个mysql数据的配置实例,安装目录为/usr/local/mysql3307/ 6.目录创建(-p父目录不存在则创建此目录) [[email protected] ~]# cd mysql-5.6.35 [[email protected] mysql-5.6.35]# mkdir -p /usr/local/mysql3307/data 7.编译安装 [[e

centos6.5下源码安装mysql密码修改

Centos下源码安装mysql密码破解方法: 方法一:首先停止mysql服务,: /etc/init.d/mysqldstop 停止mysql ps -ef |grep mysql 查看mysql是否关闭 然后以跳过权限方式后台启动 /usr/local/mysql/bin/mysqld_safe--skip-grant-tables --user=mysql & /usr/local/mysql/bin/mysql进入mysql 或者执行mysql回车进入mysql,然后修改密码. 修改My

源码安装mysql

创建mysql组:groupadd mysql 创建mysql用户并赋予这个mysq组中,不创建家目录,不允许用户登录.(因为刚刚创建的mysql是虚拟用户,所以不允许登录)useradd mysql -g mysql -M -s /bin/nologin 源码安装mysql 解压后进行编译安装:./configure \--prefix=/application/mysql5.1.72 \--with-unix-socket-path=/application/mysql5.1.72/tmp/

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

centos6.5源码安装rubyonrails及其gem插件

centos6.5源码安装ruby  on   rails 环境centos6.5  64bit 准备工作: 安装这些插件用于接下来ruby源码安装 说明: gcc 安装编译环境所用 RubyGems是用来安装ruby扩展包的模块,必要安装 在线安装: # yum install gcc # yum install make # yum install gcc-c++ 1安装ruby (1)下载ruby源文件 进入你想存放到目录,下载ruby源文件,默认下载到当前所在到目录#(cd /cfb)

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/

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

centos6.4 源码安装httpd

什么是源码  编译器 可运行档 在 Linux 系统上面,一个文件能不能被运行看的是有没有可运行的那个权限 (具有 x permission),不过,Linux 系统上真正认识的可运行档其实是二进位文 ( binary program), /usr/bin/passwd, /bin/touch 这些个文件即为二进位程序码 在 Linux 上面最标准的程序语言为 C ,所以我使用 C 的语法进行原始程序码的书写,写完之后,以 Linux 上标准的 C 语言编译器 gcc 这支程序来编译,就可以制作