0

0

MySQL 5.5源码安装_MySQL

php中文网

php中文网

发布时间:2016-06-01 13:28:48

|

1242人浏览过

|

来源于php中文网

原创

bitsCN.com

 mysql 5.5源码安装

 

首先,我们要准备MySQL,至于在什么地方下载,想必不用多说,这个可难不倒聪明的小伙伴们。本文使用的MySQL版本是5.5.29,假设读者已经把该版本或者5.5的其他版本准备好了,下面正式讲解怎样安装MySQL 5.5。本文的操作均在虚拟机下完成。

第一步,真实机拷贝MySQL 5.5源码包到虚拟机下

[root@serv01 ~]# yum install /usr/bin/scp -y

[root@larrywen ule-mysql]# scpmysql-5.5.29.tar.gz 192.168.1.11:/opt

root@192.168.1.11's password:

mysql-5.5.29.tar.gz                                                                                100%   24MB  23.7MB/s  00:00

第二步,对源码进行编译需要make等命令,所以我们安装开发工具包

[root@serv01 ~]# yum grouplist | grep Devel

  Additional Development

  Desktop Platform Development

  Development tools

  Server Platform Development

[root@serv01 ~]# yum groupinstall"Development tools" -y

 

第三步,解压源码包到/usr/src目录,/usr/src是建议命令

[root@serv01 opt]# tar -xvf mysql-5.5.29.tar.gz -C /usr/src/

第四步,进入MySQL的解压目录

 

[root@serv01 opt]# cd /usr/src/mysql-5.5.29/

#安装帮助文档(可以参考这个文件进行安装)

[root@serv01 mysql-5.5.29]# vim INSTALL-SOURCE

shell> tar zxvf mysql-VERSION.tar.gz

shell> cd mysql-VERSION

shell> cmake .

shell> make

shell> make install

# End of source-build specific instructions

# Postinstallation setup

shell> cd /usr/local/mysql

shell> chown -R mysql .

shell> chgrp -R mysql .

shell> scripts/mysql_install_db--user=mysql

shell> chown -R root .

shell> chown -R mysql data

# Next command is optional

shell> cp support-files/my-medium.cnf/etc/my.cnf

shell> bin/mysqld_safe --user=mysql &

# Next command is optional

shell> cp support-files/mysql.server/etc/init.d/mysql.server

 

第五步,因为配置环境需要使用到cmake,且MySQL依赖ncurses-devel包,所以我们安装cmake和ncurses-devel

[root@serv01 mysql-5.5.29]# yum install cmake-y

[root@serv01 mysql-5.5.29]# yum install ncurses-devel -y

 

第六步,关键步骤,这一步也是和MySQL 5.1的不同之处,使用cmake命令配置环境,如下

[root@serv01 mysql-5.5.29]# cmake .  /

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql /

-DWITH_INNOBASE_STORAGE_ENGINE=1  /

-DWITH_MYISAM_STORAGE_ENGINE=1 /

-DWITH_MEMORY_STORAGE_ENGINE=1 /

-DDEFAULT_CHARSET=utf8  /

-DDEFAULT_COLLATION=utf8_general_ci  /

-DWITH_EXTRA_CHARSETS=all /

-DMYSQL_TCP_PORT=3306  /

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock  /

-DMYSQL_DATADIR=/usr/local/mysql/data

 

解释:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql:MySQL安装目录,推荐安装到此目录

-DWITH_INNOBASE_STORAGE_ENGINE=1:安装InnoDB存储引擎

-DWITH_MYISAM_STORAGE_ENGINE=1:安装MyISAM存储引擎

-DWITH_MEMORY_STORAGE_ENGINE=1:安装内存存储引擎

-DDEFAULT_CHARSET=utf8:默认编码设置成utf8

-DDEFAULT_COLLATION=utf8_general_ci:默然校验规则是utf8_general_ci

-DWITH_EXTRA_CHARSETS=all:支持其他所有的编码

-DMYSQL_TCP_PORT=3306:MySQL端口指定为3306

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock:指定SOCK文件路径

-DMYSQL_DATADIR=/usr/local/mysql/data:MySQL数据目录

第七步,编译安装

[root@serv01 mysql-5.5.29]# make && make install

 

#确定安装目录存在

[root@serv01 mysql-5.5.29]# ls/usr/local/mysql/

bin COPYING  data  docs include  INSTALL-BINARY  lib man  mysql-test  README scripts  share  sql-bench support-files

第八步,添加mysql组和用户

[root@serv01 opt]# groupadd -g 500 mysql

[root@serv01 opt]# useradd -u 500 -g 500 -r -M -s /sbin/nologin mysql 

第九步,拷贝配置文件和启动脚本,并修改启动脚本的执行权限

[root@serv01 mysql-5.5.29]# cpsupport-files/my-medium.cnf /etc/my.cnf

cp: overwrite `/etc/my.cnf'? y

[root@serv01 mysql-5.5.29]# cpsupport-files/mysql.server /etc/init.d/mysqld

[root@serv01 mysql-5.5.29]# chmod a+x/etc/init.d/mysqld

[root@serv01 mysql-5.5.29]# ls /usr/local/mysql/data/

mysql test

第十步,改变mysql目录的拥有者和所属组,并修改my.cnf文件,添加data目录

点卡销卡源码
点卡销卡源码

点卡销卡源码是一个以php+MySQL进行开发的点卡回收平台源码。软件必须使用宝塔面板进行搭建,否则有可能会出现无法安装的问题。

下载

[root@serv01 mysql-5.5.29]# chown mysql.mysql/usr/local/mysql/ -R

[root@serv01 mysql-5.5.29]# vim /etc/my.cnf

[root@serv01 mysql-5.5.29]# cat /etc/my.cnf |grep datadir

datadir         =/usr/local/mysql/data

第十一步,修改mysql_install_db的权限,使其可执行,并进行初始化操作

[root@serv01 mysql-5.5.29]# chmod a+xscripts/mysql_install_db

[root@serv01 mysql-5.5.29]#./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/--basedir=/usr/local/mysql/

WARNING: The host 'serv01.host.com' could notbe looked up with resolveip.

This probably means that your libc librariesare not 100 % compatible

with this binary MySQL version. The MySQLdaemon, mysqld, should work

normally with the exception that host nameresolving will not work.

This means that you should use IP addressesinstead of hostnames

when specifying MySQL privileges !

Installing MySQL system tables...

OK

Filling help tables...

OK

 

To start mysqld at boot time you have to copy

support-files/mysql.server to the right placefor your system

 

PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER !

To do so, start the server, then issue thefollowing commands:

 

/usr/local/mysql//bin/mysqladmin -u rootpassword 'new-password'

/usr/local/mysql//bin/mysqladmin -u root -hserv01.host.com password 'new-password'

 

Alternatively you can run:

/usr/local/mysql//bin/mysql_secure_installation

 

which will also give you the option ofremoving the test

databases and anonymous user created bydefault.  This is

strongly recommended for production servers.

 

See the manual for more instructions.

 

You can start the MySQL daemon with:

cd /usr/local/mysql/ ;/usr/local/mysql//bin/mysqld_safe &

 

You can test the MySQL daemon withmysql-test-run.pl

cd /usr/local/mysql//mysql-test ; perlmysql-test-run.pl

 

Please report any problems with the/usr/local/mysql//scripts/mysqlbug script!

第十二步,启动MySQL,如果出现SUCCESS,恭喜您,MySQL启动成功;如果出错,不要着急,根据日志排查错误

[root@serv01 mysql-5.5.29]#/etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

[root@serv01 mysql-5.5.29]# ll/usr/local/mysql/data/ -d

drwxr-xr-x. 5 mysql mysql 4096 Sep  4 23:39 /usr/local/mysql/data/

第十三步,添加环境变量,并使其生效

[root@serv01 mysql-5.5.29]# vim~/.bash_profile

[root@serv01 mysql-5.5.29]# . !$

. ~/.bash_profile

[root@serv01 mysql-5.5.29]# cat ~/.bash_profile| grep PATH

PATH=/usr/local/mysql/bin/:$PATH:$HOME/bin

export PATH

第十四步,登录mysql,查看版本,如果出现版本号,则证明安装成功

[root@serv01 mysql-5.5.29]# mysql

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

Your MySQL connection id is 1

Server version: 5.5.29-log Sourcedistribution

 

Copyright (c) 2000, 2012, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks oftheir respective

owners.

 

Type 'help;' or '/h' for help. Type '/c' toclear the current input statement.

 

mysql> select version();

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

| version() |

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

| 5.5.29-log |

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

1 row in set (0.00 sec)

 

mysql> exit

Bye

 

如果需要安装多个MySQL,需要修改端口,修改sock文件

[root@serv01 mysql-5.5.29]# cat /etc/my.cnf |grep -e sock -e port

port              =3306

socket           =/tmp/mysql.sock

bitsCN.com

相关专题

更多
ip地址修改教程大全
ip地址修改教程大全

本专题整合了ip地址修改教程大全,阅读下面的文章自行寻找合适的解决教程。

86

2025.12.26

压缩文件加密教程汇总
压缩文件加密教程汇总

本专题整合了压缩文件加密教程,阅读专题下面的文章了解更多详细教程。

50

2025.12.26

wifi无ip分配
wifi无ip分配

本专题整合了wifi无ip分配相关教程,阅读专题下面的文章了解更多详细教程。

100

2025.12.26

漫蛙漫画入口网址
漫蛙漫画入口网址

本专题整合了漫蛙入口网址大全,阅读下面的文章领取更多入口。

293

2025.12.26

b站看视频入口合集
b站看视频入口合集

本专题整合了b站哔哩哔哩相关入口合集,阅读下面的文章查看更多入口。

589

2025.12.26

俄罗斯搜索引擎yandex入口汇总
俄罗斯搜索引擎yandex入口汇总

本专题整合了俄罗斯搜索引擎yandex相关入口合集,阅读下面的文章查看更多入口。

725

2025.12.26

虚拟号码教程汇总
虚拟号码教程汇总

本专题整合了虚拟号码接收验证码相关教程,阅读下面的文章了解更多详细操作。

63

2025.12.25

错误代码dns_probe_possible
错误代码dns_probe_possible

本专题整合了电脑无法打开网页显示错误代码dns_probe_possible解决方法,阅读专题下面的文章了解更多处理方案。

30

2025.12.25

网页undefined啥意思
网页undefined啥意思

本专题整合了undefined相关内容,阅读下面的文章了解更多详细内容。后续继续更新。

94

2025.12.25

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Python全栈开发教程-入门到精通
Python全栈开发教程-入门到精通

共106课时 | 6.5万人学习

Python Web开发实战
Python Web开发实战

共0课时 | 4.2万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号