CentOS下源码安装MySQL
一、创建mysql用户与组,相关目录
useradd mysql -s /sbin/nologin
mkdir /usr/local/mysql
chown -R mysql.mysql
mkdir -p /data/mysqldata
chown -R mysql.mysql /data/mysqldata
chown -R mysql.mysql /usr/local/mysql
二、安装所需要的库和软件包
必备的包和工具:
- gcc/g++ : MySQL 5.6开始,需要使用g++进行编译。
- cmake : MySQL 5.5开始,使用cmake进行工程管理,cmake需要2.8以上版本。
- bison : MySQL语法解析器需要使用bison进行编译。
- ncurses-devel: 用于终端操作的开发包。
- zlib: MySQL使用zlib进行压缩
功能需要的包:
- libxml: 用于XML输入输出方式的支持。
- openssl: 使用openssl安全套接字方式通信。
- dtrace: 用于诊断MySQL问题
1.下载安装所需要的软件
wget http://www.cmake.org/files/v2.8/cmake-2.8.11.1.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.7.tar.gz
wget wget http://ftp.gnu.org/gnu/m4/m4-1.4.17.tar.gz
#去官网下载mysql的版本:http://www.mysql.com,我的云盘:http://pan.baidu.com/s/1slaU3al
安装cmake编译器
tar -xvf cmake-2.8.11.1.tar.gz
cd cmake-2.8.11.1
./configure
make&&make install
安装m4
tar -xvf m4-1.4..tar.gz
cd m4-1.4.
./configure && make && make install
安装bison
tar xf bison-2.7.tar.gz
cd bison-2.7
./configure
make
make install
2.安装所需要的库文件
yum -y install gcc gcc-c++ ncurses-devel openssl zlib-devel perl autoconf
三、安装Mysql
有关MySQL编译参数:
MAKE_BUILD_TYPE 编译的版本类型:RelWithDebInfo和Debug,不同之处是RelWithDebInfo会进行优化。
CMAKE_INSTALL_PREFIX 指定make install安装的目标路径。
SYSCONFDIR 指定配置文件的默认路径。
MYSQL_DATADIR 指定data目录的默认路径。
WITH_DEBUG 指定是否有debugging信息,一般用于源码调试时,打开WITH_DEBUG,生产环境关闭。
ENABLED_PROFILING 指定是否可以使用show profile显示操作执行的详细信息。
DEFAULT_CHARSET 指定默认字符集,可以在启动的配置文件中指定。
DEFAULT_COLLATION 指定默认字符比较、排序的规则。
WITH_EXTRA_CHARSETS 指定其他可能使用的字符集。
WITH_SSL 指定SSL的类型,从5.6.6开始默认bundled类型,此外也可以指定SSL库的路径地址。
WITH_ZLIB 指定zlib的类型,用于压缩功能。
ENABLED_LOCAL_INFILE 指定是否允许使用load data infile功能。
WITH_EMBEDDED_SERVER 指定是否编译libmysqld嵌入式库。
INSTALL_LAYOUT 指定安装的布局类型。
WITH_storage_STORAGE_ENGINE 指定编译支持的存储引擎,默认支持MyISAM,MERGE,MEMORY,CSV存储引擎。
更多详细参数可参考 http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
编译安装
cd /usr/local/src
tar -xvf mysql-5.6..tar.gz
cd mysql-5.6.
cmake -DCMAKE_INSTLL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/data/mysqldata -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=utf8,gbk -DWITH_PERFSCHEMA_STORAGE_ENGINE= -DWITH_FEDERATED_STORAGE_ENGINE= -DWITH_PARTITION_STORAGE_ENGINE= -DWITH_ARCHIVE_STORAGE_ENGINE= -DWITH_INNOBASE_STORAGE_ENGINE= -DWITH_BLACKHOLE_STORAGE_ENGINE= -DENABLE_DOWNLOADS=1
make
make install
删除系统的默认配置文件
rm -rf /etc/my.cnf
初始化数据库
cd /usr/local/mysql/
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldata/
创建配置文件的软连接文件:
ln -s /usr/local/mysql/my.cnf /etc/my.cnf
将mysqld服务程序添加到开机启动项:
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod /etc/rc.d/init.d/mysqld
chkconfig mysqld on
编辑启动项的配置文件:
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysqldata
启动mysqld服务程序:
service mysqld start
把mysql服务程序命令目录添加到环境变量中(永久生效):
echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
将mysqld服务程序的库文件链接到默认的位置:
mkdir /var/lib/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
初始化mysqld服务程序:
[root@lnmp mysql]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password: 输入要为root用户设置的数据库密码。
Re-enter new password: 重复再输入一次密码。
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y(删除匿名帐号)
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y(禁止root用户从远程登陆)
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y(删除test数据库并取消对其的访问权限)
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y(刷新授权表,让初始化后的设定立即生效)
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
修改字符集和数据存储路径
[client]
password = 123456
port = 3306
default-character-set=utf8
[mysqld]
port = 3306
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
#(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写)
lower_case_table_names=1
#(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; )
max_connections=1000
[mysql]
default-character-set = utf8
CentOS下源码安装MySQL的更多相关文章
- centos 6x系统下源码安装mysql操作记录
在运维工作中经常部署各种运维环境,涉及mysql数据库的安装也是时常需要的.mysql数据库安装可以选择yum在线安装,但是这种安装的mysql一般是系统自带的,版本方面可能跟需求不太匹配.可以通过源 ...
- CentOS 7下源码安装MySQL 5.7
网上说linux安装mysql服务分两种安装方法: ①源码安装,优点是安装包比较小,只有几十M左右,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: ②使用官方编译好的二进制文件安装,优点 ...
- CentOS下源码安装Apache2.4+PHP5.4+MySQL5.5
一.准备(把所有的源文件放在‘/home/yuanjun’目录下) apr http://mirror.bjtu.edu.cn/apache/apr/apr-1.4.6.tar.gz apr-util ...
- lnux下源码安装MySQL 5.6
nux下源码安装MySQL 5.6 说明:本文是我自己测试的MySQL5.6源码安装,经本人亲自实践,完全可用,另在5.6之前的版本也是可以按照本文源码安装的.我是在两台linux下一台安装5.5,另 ...
- Linux平台下源码安装mysql多实例数据库
Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...
- CentOS 7下源码安装MySQL 5.6
本文转载,并非原创. 目录 准备工作 运行环境 确认你的安装版本 下载MySQL 安装MySQL 准备安装环境 编译和安装 配置MySQL 单实例配置 单实例配置方法 添加防火墙 启动MySQL 重启 ...
- CentOS 6.5下源码安装MySQL 5.6
变量lower_case_file_system说明是否数据目录所在的文件系统对文件名的大小写敏感.ON说明对文件名的大小写不敏感,OFF表示敏感. 在my.cnf中[mysqld]更改lower_c ...
- CentOS下源码安装vsftpd-3.0.0,并设置指定用户访问指定目录(附带完整配置文件)
1.卸载系统已经存在的ftp服务器 因为是源码安装,所以不能通过rpm -qa的方式查看是否已经安装ftp服务器,可以通过find / | grep vsftp*方式查看系统中存在哪些与vsftpd相 ...
- 在 CentOS 下源码安装 Xen
http://www.vpsee.com/2010/04/install-xen-on-centos-from-source/ 在 CentOS 源码编译安装 Xen 的过程和在 Debian 上编译 ...
随机推荐
- ECshop中TemplateBeginEditable 和后台编辑讲解
在ecshop的dwt文件里面经常发现有“<!-- TemplateBeginEditable name="doctitle" -->和<!-- #BeginLi ...
- 每日一九度之题目1016:火星A+B
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5346 解决:1464 题目描述: 读入两个不超过25位的火星正整数A和B,计算A+B.需要注意的是:在火星上,整数不是单一进制的, ...
- 【转】身份证号码校验与信息提取 - Java 代码
转载地址:http://www.w3china.org/blog/more.asp?name=lhwork&id=19148 import java.util.regex.*; /** ...
- html里文本保留换行格式
用<pre></pre>把文本包起来
- YTU 2990: 链表的基本运算(线性表)
2990: 链表的基本运算(线性表) 时间限制: 1 Sec 内存限制: 128 MB 提交: 1 解决: 1 题目描述 编写一个程序,实现链表的各种基本运算(假设顺序表的元素类型为char),主 ...
- python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案
python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案 importerror:no mo ...
- CRB and String
CRB and String Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...
- 多校赛3- Painter 分类: 比赛 2015-07-29 19:58 3人阅读 评论(0) 收藏
D - Painter Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status P ...
- Network 分类: POJ 图论 2015-07-27 17:18 17人阅读 评论(0) 收藏
Network Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14721 Accepted: 5777 Special Judg ...
- Linux内核2.4.x的网络接口源码的结构[转]
http://blog.csdn.net/wswifth/article/details/5102242 一.前言 Linux的源码里,网络接口的实现部份是非常值得一读的,通过读源码,不仅对网络协议会 ...