码迷,mamicode.com
首页 > 数据库 > 详细

mysql 5.5.6 源码安装配置

时间:2015-03-30 19:08:43      阅读:369      评论:0      收藏:0      [点我收藏+]

标签: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   软件解压路径存放路径

[root@web1_lamp/]# mkdir /soft/tool/ -p   软件包存放位置

[root@web1_lamp /]# wgethttp://mirrors.163.com/.help/CentOS-Base-163.repo

[root@web1_lamp /]# yum makecache   安装yum源

[root@web2_lnmp ~]#yum groupinstall "Development tools"

 [root@web1_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

  [root@web1_lamp /]# groupadd mysql

[root@web1_lamp /]# useradd -g mysql -s /sbin/nologinmysql -M

  [root@web1_lamp /]# mkdir /data  数据存储路径

  [root@web1_lamp/]#  chown -R mysql. /data/

  [root@web1_lamp /]#cd /soft/tool/

  [root@web1_lamp tool]# tar zxf mysql-5.6.23.tar.gz-C /usr/local/src/

  [root@web1_lamptool]# cd /usr/local/src/mysql-5.6.23/

[root@mysql-b 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

 

[root@web1_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的包去编译安装

 [root@web1_lamplib64]# cd /soft/tool/

  [root@web1_lamptool]# unzip gmock-1.6.0.zip -d/usr/local/src/mysql-5.6.23/source_downloads/

[root@web1_lamp tool]# cd /usr/local/src/ mysql-5.6.23/source_downloads/gmock-1.6.0/

[root@web1_lamp gmock-1.6.0]# ./configure

[root@web1_lamp gmock-1.6.0]# make

[root@web1_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

[root@web1_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

[root@web1_lamp mysql-5.6.23]# make && makeinstall  

2.3.1  mysql 配置

[root@mysql-a mysql-5.6.23]# cd /usr/local/mysql/

[root@mysql-a mysql]# chown -R mysql .

[root@mysql-a mysql]#  chgrp -R mysql .

[root@mysql-a /]# chown -R mysql. /data

[root@mysql-a 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

[root@mysql-a mysql]# chown -R mysql. /var/lib/mysql/

[root@mysql-a mysql]# cp support-files/mysql.server/etc/init.d/mysql

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

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

[root@mysql-b 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!

 

[root@mysql-a mysql]# /usr/local/mysql/bin/mysqld_safe&  启动mysql的守护进程

[root@mysql-a mysql]# cpsupport-files/mysql.server /etc/init.d/mysql

[root@mysql-a mysql]# chmod 755 /etc/init.d/mysql

[root@mysql-a mysql]# chkconfig --add mysql

[root@mysql-a mysql]# echo"PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

[root@mysql-a mysql]# echo "export PATH">> /etc/profile

[root@mysql-a mysql]# source /etc/profile

[root@mysql-a mysql]# /etc/init.d/mysql start

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

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

[root@mysql-a 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

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

[mysqld]

datadir=/data/  

[root@web2_lnmp mysql]# /etc/init.d/mysql start

Starting MySQL... SUCCESS!

Mysql 启动报错总结:

[root@mysql-a 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).

[root@web2_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

[root@mysql-a mysql]#  kill 25588

[root@mysql-a mysql]#  kill 25689

[root@mysql-a mysql]#  ps -ef|grep mysql

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

[root@mysql-a mysql]#  /etc/init.d/mysql restart

Shutting down MySQL. SUCCESS!

Starting MySQL. SUCCESS! 启动ok

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

[root@mysql-b mysql]# cp support-files/my-default.cnf/etc/my.cnf

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

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

如果启动报错:

[root@mysql-a 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).

解决方法:

[root@mysql-a mysql]# cp support-files/my-default.cnf/etc/my.cnf 

[root@mysql-a mysql]# /etc/init.d/mysql restart

 ERROR! MySQLserver PID file could not be found!

Starting MySQL. SUCCESS!  

然后去修改配置文件

默认的my.cnf

[root@mysql-a 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

[root@mysql-a 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

[root@mysql-a 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 默认的配置文件需要修改。


本文出自 “小菜鸟” 博客,请务必保留此出处http://xiaocainiaox.blog.51cto.com/4484443/1626386

mysql 5.5.6 源码安装配置

标签:mysql 5.5.6 源码安装配置

原文地址:http://xiaocainiaox.blog.51cto.com/4484443/1626386

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!