说明:CentOS 6.6 下源码编译安装MySQL 5.7.5 1. 安装相关工具# yum -y install gcc-c++ ncurses-devel cmake make perl \ gcc a
说明:CentOS 6.6 下源码编译安装MySQL 5.7.5
1. 安装相关工具
# yum -y install gcc-c++ ncurses-devel cmake make perl \
gcc autoconf automake zlib libxml libgcrypt libtool bison
2. 清理环境
检查boost版本:
# rpm -qa boost*
卸载boost-*等库:
# yum -y remove boost-*
3. mysql源码包下载
mysql5.7源码下载:
mysql镜像站:
4. 创建mysql用户, 组及目录
# groupadd mysql
# mkdir /home/mysql
# mkdir /home/mysql/data
# useradd -g mysql -d /home/mysql
5. 注意事项
从MySQL 5.7.5开始Boost库是必需的,下载Boost库,在解压后复制到/usr/local/boost目录下,然后重新cmake并在后面的选项中加上选项 -DWITH_BOOST=/usr/local/boost
(下载:)
需求boost1.57.0
wget -c
6. 新版本的mysq用cmake编译安装
解压mysql源码包mysql-5.7.5-m15.tar.gz
# tar -xzvf mysql-5.7.5-m15.tar.gz
以下操作在解压后的源码包的根目录执行
cmake编译
# cmake -DCMAKE_INSTALL_PREFIX=/home/mysql -DMYSQL_DATADIR=/home/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
常用参数:
CMAKE_INSTALL_PREFIX:指定MySQL程序的安装目录,默认/usr/local/mysql
DEFAULT_CHARSET:指定服务器默认字符集,默认latin1
DEFAULT_COLLATION:指定服务器默认的校对规则,默认latin1_general_ci
ENABLED_LOCAL_INFILE:指定是否允许本地执行LOAD DATA INFILE,默认OFF
WITH_COMMENT:指定编译备注信息
WITH_xxx_STORAGE_ENGINE:指定静态编译到mysql的存储引擎,MyISAM,MERGE,MEMBER以及CSV四种引擎默认即被编译至服务器,不需要特别指定。
WITHOUT_xxx_STORAGE_ENGINE:指定不编译的存储引擎
SYSCONFDIR:初始化参数文件目录
MYSQL_DATADIR:数据文件目录
MYSQL_TCP_PORT:服务端口号,,默认3306
MYSQL_UNIX_ADDR:socket文件路径,默认/tmp/mysql.sock
编译安装
# make && make install
出错后重新运行配置,需要删除CMakeCache.txt文件
# make clean
# rm -f CMakeCache.txt
7. 设置权限并初始化MySQL系统授权表
设置权限
# cd /home/mysql
# chown -R mysql .
# chgrp -R mysql .
以root初始化操作时要加–user=mysql参数,生成一个随机密码(注意保存登录时用)
# cd /home/mysql
# bin/mysqld --initialize --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data
8. 创建配置文件
将默认生成的my.cnf备份
# mv /etc/my.cnf /etc/my.cnf.bak
进入mysql的安装目录支持文件目录
# cd /home/mysql/support-files
拷贝配置文件模板为新的mysql配置文件,
# cp my-default.cnf /etc/my.cnf
可按需修改新的配置文件选项, 不修改配置选项, mysql则按默认配置参数运行.
如下是我修改配置文件/etc/my.cnf, 用于设置编码为utf8以防乱码
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
[client]
default-character-set=utf8
9. 配置mysql服务开机自动启动
拷贝启动文件到/etc/init.d/下并重命令为mysqld
# cp /home/mysql/support-files/mysql.server /etc/init.d/mysql
增加执行权限
# chmod 755 /etc/init.d/mysqld
检查自启动项列表中没有mysqld这个,如果没有就添加mysqld:
# chkconfig --list mysqld
# chkconfig --add mysqld
设置MySQL在345等级自动启动
# chkconfig --level 345 mysqld on
或用这个命令设置开机启动:
# chkconfig mysqld on
10. mysql服务的启动/重启/停止
启动mysql服务
# service mysqld start
重启mysql服务
# service mysqld restart
停止mysql服务
# service mysqld stop
11. 访问mysql数据库
连接mysql, 输入初始化生成的随机密码
# mysql -uroot -p
修改root新密码如 123456
mysql> alter user 'root'@'localhost' identified by '123456';
mysql> quit;
mysql> exit;(与上等效, 都是退出mysql连接)
使用新密码重新连接mysql
# mysql -uroot -p
以下是小编为您精心挑选的MySQL相关内容,看看是否有所帮助:
Linux下安装编译MySQL5.5.28
Linux下MySQL 5.6.23安装
CentOS 7下源码安装MySQL 5.6
MySQL5.7.3.0安装配置图解教程
Ubuntu 14.04下安装MySQL
《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
Ubuntu 14.04下搭建MySQL主从服务器
Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群
Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb
MySQL-5.5.38通用二进制安装
本文永久更新链接地址:

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
