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 默認的配置文件需要修改。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章