search
HomeDatabaseMysql TutorialCentOS 6.6 下源码编译安装MySQL 5.7.5

说明: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通用二进制安装

本文永久更新链接地址

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are stored procedures in MySQL?What are stored procedures in MySQL?May 01, 2025 am 12:27 AM

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

How does query caching work in MySQL?How does query caching work in MySQL?May 01, 2025 am 12:26 AM

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

What are the advantages of using MySQL over other relational databases?What are the advantages of using MySQL over other relational databases?May 01, 2025 am 12:18 AM

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor