mysql 5.5.6 源码安装配置

http://dev.mysql.com/doc/refman/5.6/en/index.html  mysql官网安装手册

http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html源码安装说明

根据官网文档将安装过程写成一个批处理文件mysql.install安装完毕之后需要修改配置文件

修改编码,防止乱码

my.cnf 配置参考http://dev.mysql.com/doc/refman/5.6/en/option-files.html

/usr/local 安装路径为/usr/local 软件的统一安装路径

/usr/local/src   软件解压路径存放路径

[[email protected]_lamp/]# mkdir /soft/tool/ -p   软件包存放位置

[[email protected]_lamp /]# wgethttp://mirrors.163.com/.help/CentOS-Base-163.repo

[[email protected]_lamp /]# yum makecache   安装yum源

[[email protected]_lnmp ~]#yum groupinstall "Development tools"

[[email protected]_lamp/]#  yum -y install  autoconf* automake* zlib* libxml*ncurses-devel ncurses libgcrypt* libtool* cmakeopenssl openssl-devel bison bison-devel unzip openssl openssl-devel  libssl-dev

[[email protected]_lamp /]# groupadd mysql

[[email protected]_lamp /]# useradd -g mysql -s /sbin/nologinmysql -M

[[email protected]_lamp /]# mkdir /data  数据存储路径

[[email protected]_lamp/]#  chown -R mysql. /data/

[[email protected]_lamp /]#cd /soft/tool/

[[email protected]_lamp tool]# tar zxf mysql-5.6.23.tar.gz-C /usr/local/src/

[[email protected]_lamptool]# cd /usr/local/src/mysql-5.6.23/

[[email protected] mysql-5.6.23]# vim INSTALL-SOURCE

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd 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

shell> bin/mysqld_safe --user=mysql &

# Next command is optional

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

[[email protected]_lamp mysql-5.6.23]# cmake –help  è查看编译选项

time cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DSYSCONFDIR=/etc \

-DMYSQL_DATADIR=/data  \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DMYSQL_USER=mysql\

-DEXTRA_CHARSETS=all  \

-DWITH_READLINE=1 \

-DWITH_SSL=system \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DENABLE_DOWNLOADS=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

--Library mysqlclient depends on OSLIBS-lpthread;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl

-- Download failed, error: 28;"Timeoutwas reached"

-- To enable google test, please downloadhttp://googlemock.googlecode.com/files/gmock-1.6.0.zip to the directory/usr/local/app/mysql-5.6.23/source_downloads

-- If you are inside a firewall, you may needto use an http proxy: export http_proxy=http://example.com:80

-- Library mysqlserver depends on OSLIBS-lpthread;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl;crypt

http://www.filewatcher.com/m/gmock-1.6.0.zip.2053682-0.html  去下载gmock的包去编译安装

[[email protected]_lamplib64]# cd /soft/tool/

[[email protected]_lamptool]# unzip gmock-1.6.0.zip -d/usr/local/src/mysql-5.6.23/source_downloads/

[[email protected]_lamp tool]# cd /usr/local/src/ mysql-5.6.23/source_downloads/gmock-1.6.0/

[[email protected]_lamp gmock-1.6.0]# ./configure

[[email protected]_lamp gmock-1.6.0]# make

[[email protected]_lamp gmock-1.6.0]# cd /usr/local/src/mysql-5.6.23

Mysql 官网编译参数说明

http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html#option_cmake_with_libedit

[[email protected]_lampmysql-5.6.23]#

time cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DSYSCONFDIR=/etc \

-DMYSQL_DATADIR=/data \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld.sock\

-DMYSQL_TCP_PORT=3306 \

-DMYSQL_USER=mysql \

-DEXTRA_CHARSETS=all  \

-DWITH_READLINE=1\

-DWITH_SSL=system\

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DENABLE_DOWNLOADS=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

[[email protected]_lamp mysql-5.6.23]# make && makeinstall

2.3.1  mysql 配置

[[email protected] mysql-5.6.23]# cd /usr/local/mysql/

[[email protected] mysql]# chown -R mysql .

[[email protected] mysql]#  chgrp -R mysql .

[[email protected] /]# chown -R mysql. /data

[[email protected] mysql]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql--datadir=/data

2015-03-16 07:58:13 25759 [Note] InnoDB: Shutdowncompleted; log sequence number 1625987

OK

To start mysqld at boot time you have to copy

support-files/mysql.serverto the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!

To do so, start the server, then issue the followingcommands:

/usr/local/mysql/bin/mysqladmin-u root password ‘new-password‘

/usr/local/mysql/bin/mysqladmin -u root -hmysql-b password ‘new-password‘  设置root登陆mysql的密码

Alternatively you can run:

/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

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

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perlmysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on theweb at

http://www.mysql.com

[[email protected] mysql]# chown -R mysql. /var/lib/mysql/

[[email protected] mysql]# cp support-files/mysql.server/etc/init.d/mysql

[[email protected]]#  /usr/local/mysql/bin/mysqladmin-u root password ‘password‘    可执行也不可执行

Warning: Using a password on the command line interfacecan be insecure.

[[email protected] mysql]#/usr/local/mysql/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FORALL MySQL

SERVERS INPRODUCTION USE!  PLEASE READ EACH STEPCAREFULLY!

In order to log into MySQL to secure it, we‘ll need thecurrent

password for the root user.  If you‘ve just installed MySQL, and

you haven‘t set the root password yet, the password willbe 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 loginto the MySQL

root user without the proper authorisation.

You already have a root password set, so you can safelyanswer ‘n‘.

Change the root password? [Y/n] y

New password:

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 accountcreated for

them.  This isintended 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 passwordfrom the network.

Disallow root login remotely? [Y/n] y

... Success!

By default, MySQL comes with a database named ‘test‘ thatanyone can

access.  This isalso intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y

- Dropping testdatabase...

... Success!

- Removingprivileges on test database...

... Success!

Reloading the privilege tables will ensure that allchanges made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

All done!  Ifyou‘ve completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

[[email protected] mysql]# /usr/local/mysql/bin/mysqld_safe&  启动mysql的守护进程

[[email protected] mysql]# cpsupport-files/mysql.server /etc/init.d/mysql

[[email protected] mysql]# chmod 755 /etc/init.d/mysql

[[email protected] mysql]# chkconfig --add mysql

[[email protected] mysql]# echo"PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

[[email protected] mysql]# echo "export PATH">> /etc/profile

[[email protected] mysql]# source /etc/profile

[[email protected] mysql]# /etc/init.d/mysql start

Starting MySQL..... ERROR! The server quit withoutupdating PID file (/var/lib/mysql/web1_lamp.pid).

出现error 就要去查看mysql的日志

[[email protected] mysql]#  more /var/log/mysqld.log

2015-02-28 00:28:53 47294 [ERROR] Fatalerror: Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exist

150228 00:28:53 mysqld_safe mysqld from pidfile /var/lib/mysql/web2_lnmp.pid ended

150228 00:32:23 mysqld_safe Starting mysqlddaemon with databases from /data/

2015-02-28 00:32:24 0 [Warning] TIMESTAMP with implicitDEFAULT value is deprecated. Please use --explicit_defaults_f

or_timestamp server option (see documentation for moredetails).

从日志看到/var/lib/mysql/web2_lnmp.pidended打开数据库和表失败,默认的数据路径为/data

[[email protected] mysql]#  vim /etc/my.cnf

[mysqld]

datadir=/data/

[[email protected]_lnmp mysql]# /etc/init.d/mysql start

Starting MySQL... SUCCESS!

Mysql 启动报错总结:

[[email protected] mysql]#  /etc/init.d/mysql restart

ERROR!MySQL server PID file could not be found!

Starting MySQL... ERROR! The server quitwithout updating PID file (/data/mysql-b.pid).

[[email protected]_lnmp mysql]# ps -ef |grep mysql

root     47351      1  0 00:32 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe--datadir=/data

--pid-file=/data//web2_lnmp.pid

mysql    47527  47351  0 00:32 pts/1    00:00:01 /usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql --datadir=/data/--plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log--pid-file=/data//web2_lnmp.pid --socket=/var/lib/mysql/mysql.sock

root     47610   2817  0 00:48 pts/1    00:00:00 grep mysql

[[email protected] mysql]#  kill 25588

[[email protected] mysql]#  kill 25689

[[email protected] mysql]#  ps -ef|grep mysql

root     26111   5590  0 08:05 pts/0    00:00:00 grep mysql

[[email protected] mysql]#  /etc/init.d/mysql restart

Shutting down MySQL. SUCCESS!

Starting MySQL. SUCCESS! 启动ok

如果/etc/my.cnf 没有生成,拷贝模板过去参照官网进行修改

[[email protected] mysql]# cp support-files/my-default.cnf/etc/my.cnf

编译的时候我指定配置文件的路径了,但是没有生成,拷贝一个模板到/etc/

修改/etc/init.d/mysql 的启动脚本

如果启动报错:

[[email protected] mysql]# /etc/init.d/mysqlrestart

ERROR!MySQL server PID file could not be found!

Starting MySQL.. ERROR! The server quitwithout updating PID file (/var/lib/mysql/mysql-a.pid).

解决方法:

[[email protected] mysql]# cp support-files/my-default.cnf/etc/my.cnf

[[email protected] mysql]# /etc/init.d/mysql restart

ERROR! MySQLserver PID file could not be found!

Starting MySQL. SUCCESS!

然后去修改配置文件

默认的my.cnf

[[email protected] mysql]# cat support-files/my-default.cnf

# For advice on how to change settings please see

#http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It‘s a template which willbe copied to the

# *** default location during install, and will bereplaced if you

# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for themost important data

# cache in MySQL. Start at 70% of total RAM for dedicatedserver, else 10%.

# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important dataintegrity option: logging

# changes to the binary log between backups.

# log_bin

# These are commonly set, remove the # and set asrequired.

# basedir = .....

# datadir = .....

# port = .....

# server_id = .....

# socket = .....

# Remove leading # to set options mainly useful forreporting servers.

# The server defaults are faster for transactions andfast SELECTs.

# Adjust sizes as needed, experiment to find the optimalvalues.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[[email protected] mysql]# diff /etc/my.cnfsupport-files/my-default.cnf

2a3,5

> # *** DO NOT EDIT THIS FILE. It‘s a template whichwill be copied to the

> # *** default location during install, and will bereplaced if you

> # *** upgrade to a newer version of MySQL.

15,19c18,22

<  basedir =/usr/local/mysql

<  datadir =/data

<  port = 3306

<  #server_id =......

<  socket =/usr/local/mysql/mysql.sock

---

> # basedir = .....

> # datadir = .....

> # port = .....

> # server_id = .....

> # socket = .....

29,31d31

<  [mysql]   添加客户端连接

<  port=3306   端口可以修改为

< socket=/usr/local/mysql/mysql.sock

[[email protected] mysql]# mysql -uroot   登陆成功,mysql的安装完成

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

Your MySQL connection id is 1

Server version: 5.6.23 Source distribution

Copyright (c) 2000, 2015, Oracle and/or its affiliates.All rights reserved.

Oracle is a registered trademark of Oracle Corporationand/or its

affiliates. Other names may be trademarks of theirrespective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear thecurrent input statement.

mysql>

mysql错误总结,主要是安装目录的权限和my.cnf 默认的配置文件需要修改。

时间: 2024-08-06 18:47:57

mysql 5.5.6 源码安装配置的相关文章

MySQL系列 - MySQL源码安装配置

二.MySQL系列 - MySQL源码安装配置(附5.7等最新版本)1.依赖环境准备2.开始安装2.1.下载MySQL2.2.解压2.3.赋权限2.4.修改配置文件2.5.启动MySQL3.MySQL 5.7源码安装不同之处 二.MySQL系列 - MySQL源码安装配置(附5.7等最新版本) 1.依赖环境准备 make安装 make编译器下载地址:http://www.gnu.org/software/make/ # tar zxvf make-3.82.tar.gz # cd make-3.

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Mysql (二)

mysql 简介: MySQL是一个关系型数据库管理系统,关系数据库将数据保存在不同的表中,这样就增加了速度并提高了灵活性.目前其属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件.MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言. 安装环境: 系统: centos 7.0 最小化安装 软件

Centos 7.0 编译安装LNMP(Linxu+nginx+mysql+php)之源码安装nginx (一)

nginx简介:       Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日. 其将源代码以类BSD许可证的形式发布,因它的稳定性.丰富的功能集.示例配置文件和低系统资源的消耗而闻名.2011年6月1日,nginx 1.0.4发布. Nginx是一款轻量级的Web 服务器

MySQL 5.5.17 源码安装

工作需要使用MySQL,在linux中用yum安装,安装路径不可控,不能对它进行定制,为了更好的管理MySQL Sever,采用源码安装. MySQL 5.5.17安装需要使用cmake编译工具,可以使用yum 来安装cmake 安装MySQL DB 创建相关用户组及用户  groupadd mysql  useradd –g mysql mysql 在存放MySQL源码包路径解压并且安装(手动创建相应安装目录) #mkdir /opt/mysql #chown -R mysql:mysql /

linux小白 mysql5.0源码安装配置

安装mysql-5.0.45.tar.gz(该软件包下载地址:http://www.filewatcher.com/m/mysql-5.0.45.tar.gz.24433261-0.html) # groupadd mysql              #添加mysql组 # useradd -g mysql mysql      #添加mysql用户,且加入mysql组 --------------------编译过程---------------------------------- # t

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装php (三)

PHP简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域.PHP 独特的语法混合了C.Java.Perl以及PHP自创的语法.它可以比CGI或者Perl更快速地执行动态网页.用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标

apr apr-util apache 源码安装 配置系统服务

在官网下载 源码包 apr-1.5.1.tar.gz apr-util-1.5.3.tar.gz httpd-2.4.10.tar.gz 安装用户是root 解压命令 tar -zxvf httpd-2.4.10.tar.gz 源码安装 apr ,apr-util ./configure --prefix=/usr/local/apr 报错:rm: cannot remove `libtoolT': No such file or directory 我直接忽略了,网上看有修改configure

Apache HTTP Server的源码安装配置及实现

Apache HTTP Server简介 Linux下最有名的.功能最丰富的WEB服务器就属Apache HTTP Server(简称Apache). Apache HTTP Server是Apache软件基金会最有名的开源项目之一,它可以在大多数操作系统上运行. 目前官网的主要版本为2.2和2.4.CentOS 6使用2.2版本,CentOS 7使用2.4版本. 目前生产环境中部署2.2版本的居多,但是2.4版本有很多新的特性,下面就简要说明以下: (1)运行时动态可装载MPM 在2.4版本中

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Apache (一)

Apache 简介: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一.它快速.可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中. 安装环境: 系统: centos 7.0 最小化安装 软件:httpd-2.4.26 依赖包:apr .apr-util .pcre .gcc .gcc-c++ .perl-dvel.perl.openssl .openssl-