设为首页 收藏本站
查看: 531|回复: 0

[经验分享] mysql 5.5.6 源码安装配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-3-31 08:18:35 | 显示全部楼层 |阅读模式
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   软件解压路径存放路径
[iyunv@web1_lamp/]# mkdir /soft/tool/ -p   软件包存放位置
[iyunv@web1_lamp /]# yum makecache   安装yum源
[iyunv@web2_lnmp ~]#yum groupinstall "Development tools"
[iyunv@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
  [iyunv@web1_lamp /]# groupadd mysql
[iyunv@web1_lamp /]# useradd -g mysql -s /sbin/nologinmysql -M
  [iyunv@web1_lamp /]# mkdir /data  数据存储路径
  [iyunv@web1_lamp/]#  chown -R mysql. /data/
  [iyunv@web1_lamp /]#cd /soft/tool/
  [iyunv@web1_lamp tool]# tar zxf mysql-5.6.23.tar.gz-C /usr/local/src/
  [iyunv@web1_lamptool]# cd /usr/local/src/mysql-5.6.23/
[iyunv@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
[iyunv@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的包去编译安装
[iyunv@web1_lamplib64]# cd /soft/tool/
  [iyunv@web1_lamptool]# unzip gmock-1.6.0.zip -d/usr/local/src/mysql-5.6.23/source_downloads/
[iyunv@web1_lamp tool]# cd /usr/local/src/ mysql-5.6.23/source_downloads/gmock-1.6.0/
[iyunv@web1_lamp gmock-1.6.0]# ./configure
[iyunv@web1_lamp gmock-1.6.0]# make
[iyunv@web1_lamp gmock-1.6.0]# cd /usr/local/src/mysql-5.6.23
Mysql 官网编译参数说明
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
[iyunv@web1_lamp mysql-5.6.23]# make && makeinstall  
2.3.1  mysql 配置
[iyunv@mysql-a mysql-5.6.23]# cd /usr/local/mysql/
[iyunv@mysql-a mysql]# chown -R mysql .
[iyunv@mysql-a mysql]#  chgrp -R mysql .
[iyunv@mysql-a /]# chown -R mysql. /data
[iyunv@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
[iyunv@mysql-a mysql]# chown -R mysql. /var/lib/mysql/
[iyunv@mysql-a mysql]# cp support-files/mysql.server/etc/init.d/mysql
[iyunv@mysql-amysql]#  /usr/local/mysql/bin/mysqladmin-u root password 'password'    可执行也不可执行
Warning: Using a password on the command line interfacecan be insecure.
[iyunv@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!
[iyunv@mysql-a mysql]# /usr/local/mysql/bin/mysqld_safe&  启动mysql的守护进程
[iyunv@mysql-a mysql]# cpsupport-files/mysql.server /etc/init.d/mysql
[iyunv@mysql-a mysql]# chmod 755 /etc/init.d/mysql
[iyunv@mysql-a mysql]# chkconfig --add mysql
[iyunv@mysql-a mysql]# echo"PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[iyunv@mysql-a mysql]# echo "export PATH">> /etc/profile
[iyunv@mysql-a mysql]# source /etc/profile
[iyunv@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的日志
[iyunv@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
[iyunv@mysql-a mysql]#  vim /etc/my.cnf
[mysqld]
datadir=/data/   
[iyunv@web2_lnmp mysql]# /etc/init.d/mysql start
Starting MySQL... SUCCESS!
Mysql 启动报错总结:
[iyunv@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).
[iyunv@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
[iyunv@mysql-a mysql]#  kill 25588
[iyunv@mysql-a mysql]#  kill 25689
[iyunv@mysql-a mysql]#  ps -ef|grep mysql
root     26111   5590  0 08:05 pts/0    00:00:00 grep mysql
[iyunv@mysql-a mysql]#  /etc/init.d/mysql restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS! 启动ok
如果/etc/my.cnf 没有生成,拷贝模板过去参照官网进行修改
[iyunv@mysql-b mysql]# cp support-files/my-default.cnf/etc/my.cnf
编译的时候我指定配置文件的路径了,但是没有生成,拷贝一个模板到/etc/
修改/etc/init.d/mysql 的启动脚本
如果启动报错:
[iyunv@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).
解决方法:
[iyunv@mysql-a mysql]# cp support-files/my-default.cnf/etc/my.cnf  
[iyunv@mysql-a mysql]# /etc/init.d/mysql restart
ERROR! MySQLserver PID file could not be found!
Starting MySQL. SUCCESS!  
然后去修改配置文件
默认的my.cnf
[iyunv@mysql-a mysql]# cat support-files/my-default.cnf
# For advice on how to change settings please see
# *** 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
[iyunv@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
[iyunv@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 默认的配置文件需要修改。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-52335-1-1.html 上篇帖子: MySQL管理之 MyISAM和InnoDB存储引擎简单对比 下篇帖子: MySQL错误代码汇总 mysql
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表