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

[经验分享] mysql安装,及cmake错误,mysql5.5与5.6参数对比

[复制链接]

尚未签到

发表于 2018-9-28 06:44:01 | 显示全部楼层 |阅读模式
  一、编写目的
  MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQL AB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。
  本文档为操作人员提供mysql-5.6安装指导。
第二章mysql安装
1、安装所需软件包
  [root@host1 ~]#yum install -y gccgcc-c++ libtool autoconf automake imake libxml2-devel expat-devel ncurses-develcmake bison
2、创建需要的用户和目录
  [root@host1~]#groupadd mysql                                                   //创建mysql用户组
  [root@host1~]#useradd -g mysql mysql                                     //创建mysql用户
  [root@host1~]#mkdir -p /data/mysql/rs                                    //创建数据存放目录
  [root@host1~]#mkdir -p /usr/local/mysqld                               //创建mysql安装目录
  [root@host1~]#chown mysql:mysql -R /data/mysql/             //修改目录的所属组和用户为mysql
  [root@host1~]#chown mysql:mysql -R /usr/local/mysqld
3、编译并安装mysql
  [root@host1~]#tar zxvf mysql-5.6.10.tar.gz                    //解压
  [root@host1~]#cd mysql-5.6.10
  [root@host1 mysql-5.6.10]# cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysqld -DMYSQL_DATADIR=/data/mysql/rs-DMYSQL_UNIX_ADDR=/data/mysql/rs/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1-DENABLED_LOCAL_INFILE=1-DDEFAULT_CHARSET=utf8 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1 -DDEFAULT_COLLATION=utf8_general_ci-DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DMYSQL_TCP_PORT=3106
  //cmake参数进行编译安装
  [root@localhostmysql-5.6.10]# make
  [root@localhostmysql-5.6.10]# make install
4、修改配置文件,启动数据库
  [root@localhost mysqld]# cpsupport-files/my-default.cnf ./my.cnf       //拷贝参数文件
  [root@localhost mysqld]# cpsupport-files/mysql.server ./server
  [root@localhost mysqld]#./scripts/mysql_install_db --user=mysql --ldata=/data/mysql/rs
  //初始化数据库
  [root@host1 mysqld]#vi server
  替换conf值为/usr/local/mysqld/my.cnf
  conf=/etc/my.cnf ----->conf=/usr/local/mysqld/my.cnf                              //修改参数文件路径
  [root@localhost mysqld]# ./server start                                                                 //启动mysql服务
  Starting MySQL.                                           [  OK  ]
5、进入数据库,修改密码
  [root@localhostmysqld]# /usr/local/mysqld/bin/mysql    //第一次进入数据库
  Welcometo the MySQL monitor.  Commands end with; or \g.

  YourMySQL connection>  Serverversion: 5.6.10 Source distribution
  Copyright(c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  Oracleis a registered trademark of Oracle Corporation and/or its
  affiliates.Other names may be trademarks of their respective
  owners.
  Type'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql>update mysql.user set Password=password("123456") whereUser="root" and Host="localhost";                                        //修改root用户登录密码
  QueryOK, 1 row affected (0.00 sec)
  Rowsmatched: 1  Changed: 1  Warnings: 0
  mysql>flush privileges;                                //更新授权表
  QueryOK, 0 rows affected (0.01 sec)
  mysql>
附录1:关于make时出现警告官网说明
  http://bugs.mysql.com/bug.php?id=47609
  [29 Nov 2010 8:26] Alexander Nozdrin
  These warnings are now in trunk (5.6).
  sql/sql_select produces the following warnings duringbuild on
  'linux x86_64 werror':
  ------------------------------------------------------
  /export/home/pb2/build/sb_0-2577370-1290600489.98/mysql-5.6.1-m5/sql/sql_select.cc:6829:warning: 'loose_scan_opt.Loose_scan_opt::bound_sj_equalities' may be useduninitialized in this function /export/home/pb2/build/sb_0-2577370-1290600489.98/mysql-5.6.1-m5/sql/sql_select.cc:6829:warning: 'loose_scan_opt.Loose_scan_opt::quick_max_loose_keypart' may be useduninitialized in this function/export/home/pb2/build/sb_0-2577370-1290600489.98/mysql-5.6.1-m5/sql/sql_select.cc:6829:warning: 'loose_scan_opt.Loose_scan_opt::best_loose_scan_key' may be useduninitialized in this function/export/home/pb2/build/sb_0-2577370-1290600489.98/mysql-5.6.1-m5/sql/sql_select.cc:6829:warning: 'loose_scan_opt.Loose_scan_opt::best_loose_scan_records' may be useduninitialized in this function/export/home/pb2/build/sb_0-2577370-1290600489.98/mysql-5.6.1-m5/sql/sql_select.cc:6829:warning: 'loose_scan_opt.Loose_scan_opt::best_max_loose_keypart' may be useduninitialized in this function/export/home/pb2/build/sb_0-2577370-1290600489.98/mysql-5.6.1-m5/sql/sql_select.cc:6829:warning: 'loose_scan_opt.Loose_scan_opt::best_loose_scan_start_key' may be useduninitialized in this function
  ------------------------------------------------------
  The thing is that those variables are left uninitializedintentionally.
  Here is what a comment in sql_select.cc says:
  ------------------------------------------------------
  We needn't initialize:
  bound_sj_equalities - protected by try_loosescan
  quick_max_loose_keypart - protected byquick_uses_applicable_index
  best_loose_scan_key - protected by best_loose_scan_cost!= DBL_MAX
  best_loose_scan_records - same
  best_max_loose_keypart - same
  best_loose_scan_start_key - same
  Not initializing them causes compiler warnings, but usingUNINIT_VAR()
  would cause a 2% CPU time loss in a 20-table plan search.
  So, until UNINIT_VAR(x) doesn't do x=0 for any C++ code,it's not used
  here.
  ------------------------------------------------------
附录2:cmake参数对照
  从mysql5.5起,mysql源码安装开始使用cmake。下面是 mysql 5.5 与以前的参数对照:
  configure Command
  CMake Command
  ./configure
  cmake .
  ./configure --help
  cmake . -LH or ccmake .
  Parameter
  configure Option
  CMake Option
  CMake Notes
  Installation base directory
  --prefix=/usr
  -DCMAKE_INSTALL_PREFIX=/usr
  mysqld directory
  --libexecdir=/usr/sbin
  -DINSTALL_SBINDIR=sbin

  interpreted>  Data directory
  --localstatedir=/var/lib/mysql
  -DMYSQL_DATADIR=/var/lib/mysql
  Config directory (for my.cnf)
  --sysconfdir=/etc/mysql
  -DSYSCONFDIR=/etc/mysql
  Plugin directory
  --with-plugindir=/usr/lib64/mysql/plugin
  -DINSTALL_PLUGINDIR=lib64/mysql/plugin

  interpreted>  Man page directory
  --mandir=/usr/share/man
  -DINSTALL_MANDIR=share/man

  interpreted>  Shared-data directory
  --sharedstatedir=/usr/share/mysql
  -DINSTALL_SHAREDIR=share
  this is where  aclocal/mysql.m4 should be installed
  Library installation  directory
  --libdir=/usr/lib64/mysql
  -DINSTALL_LIBDIR=lib64/mysql

  interpreted>  Header installation  directory
  --includedir=/usr/include/mysql
  -DINSTALL_INCLUDEDIR=include/mysql

  interpreted>  Info doc directory
  --infodir=/usr/share/info
  -DINSTALL_INFODIR=share/info

  interpreted>  Parameter
  configure Option
  CMake Option
  CMake Notes
  readline library
  --with-readline
  -DWITH_READLINE=1
  SSL library
  --with-ssl=/usr
  -DWITH_SSL=system
  zlib library
  --with-zlib-dir=/usr
  -DWITH_ZLIB=system
  libwrap library
  --without-libwrap
  -DWITH_LIBWRAP=0
  TCP/IP port number
  --with-tcp-port-=3306
  -DMYSQL_TCP_PORT=3306
  UNIX socket file
  --with-unix-socket-path=/tmp/mysqld.sock
  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
  Enable LOCAL for LOAD DATA
  --enable-local-infile
  -DENABLED_LOCAL_INFILE=1
  Extra charsets
  --with-extra-charsets=all
  -DEXTRA_CHARSETS=all
  default is "all"
  Default charset
  --with-
  -DDEFAULT_CHARSET=utf8
  Default collation
  --with-collation=utf8_general_ci
  -DDEFAULT_COLLATION=utf8_general_ci
  Build the server
  --with-server
  none
  Build the embedded server
  --with-embedded-server
  -DWITH_EMBEDDED_SERVER=1
  libmysqld privilege control
  --with-embedded-privilege-control
  none
  always enabled?
  Install the documentation
  --without-docs
  none
  Big tables
  --with-big-tables,  --without-big-tables
  none
  tables are big by default
  mysqld user
  --with-mysqld-user=mysql
  -DMYSQL_USER=mysql
  mysql is the default
  Debugging
  --without-debug
  -DWITH_DEBUG=0
  default is debugging  disabled
  GIS support
  --with-geometry
  none
  always enabled?
  Community features
  --enable-community-features
  none
  always enabled
  Profiling
  --disable-profiling
  -DENABLE_PROFILING=0
  enabled by default
  pstack
  --without-pstack
  none
  pstack is removed
  Assembler string functions
  --enable-assembler
  none
  Build type
  --build=x86_64-pc-linux-gnu
  no equivalent
  unneeded?
  Cross-compile host
  --host=x86_64-pc-linux-gnu
  no equivalent
  unneeded?
  Client flag
  --with-client-ldflags=-lstdc++
  none
  unneeded
  Client flag
  --enable-thread-safe-client
  none
  unneeded, clients are always  thread safe
  Comment
  --with-comment='string'
  -DWITH_COMMENT='string'
  Shared/static binaries
  --enable-shared  --enable-static
  none
  there is only DISABLE_SHARED
  Memory use
  --with-low-memory
  none
  unneeded
  1.命令语法:
  重新编译时,需要清除旧的对象文件和缓存信息
  # make clean
  # rm -f  CMakeCache.txt
  2.安装选项
  CMAKE_INSTALL_PREFIX值是安装的基本目录,其他cmake选项值是不包括前缀,是相对路径名,绝对路径包括CMAKE_INSTALL_PREFIX路径。如-DINSTALL_SBINDIR=sbin的绝对路径是/usr/local/mysql/sbin
  3.存储引擎选项
  mysql存储引擎是插件式的,因此插件控制选项可以指定那个存储引擎安装。
  configure编译插件选项--with-plugins=csv,myisam,myisammrg,heap,innobase,
  archive,blackhole在cmake中没有直接对应的相同选项。对于csv,myisam,myisammrg,heap在cmake中是不需要明确指定存储引擎的名称,因为它们是强制性安装。
  可以使用以下选择来安装innodb,archive,blackhole存储引擎
  -DWITH_INNOBASE_STORAGE_ENGINE=1
  -DWITH_ARCHIVE_STORAGE_ENGINE=1
  -DWITH_BLACKHOLE_STORAGE_ENGINE=1
  (1可以使用on代替)
  如果既不是-DWITH__STORAGE_ENGINE 也不是 -DWITHOUT__STORAGE_ENGINE 来指定存储引擎,该存储引擎将安装成共享模块式的。如果不是共享模块式的将排除在外。共享模块安装时必须使用INSTALL PLUGIN语句或--plugin-load才可以使用。
  4.其他选项
  之前MySQL的编译选项大多数都支持。新旧版本之间的安装选项映射成大写字母,删除选项前面破折号,中间字符间的破折号替换成下划线。如:
  --with-debug => WITH_DEBUG=1
  --with-embedded-server => WITH_EMBEDDED_SERVER
  5.调试配置过程
  使用configure编译完将生成config.log和config.status文件。
  使用cmake编译完在CMakeFiles目录下生成CMakeError.log 和CMakeOutput.log文件。
  编译参数参考:
  BUILD_CONFIG  采用官方发行版一致的编译参数

  CMAKE_BUILD_TYPE 指定产品编译说明信息  >  CMAKE_INSTALL_PREFIX 指定MySQL安装路径  /usr/local/mysql
  CPACK_MONOLITHIC_INSTALL是否建立单个安装包文件 OFF  5.5.7
  DEFAULT_CHARSET  MYSQL 默认字符集 latin1   5.5.7
  DEFAULT_COLLATION MYSQL 默认排序字符集  latin1_swedish_ci5.5.7
  ENABLE_DEBUG_SYNC 是否启用同步调试功能  ON   5.5.7
  ENABLE_DOWNLOADS 是否下载可选文件  OFF   5.5.7
  ENABLE_DTRACE  是否包含 DTrace 支持     5.5.7
  ENABLE_GCOV  是否包含 Gcov 支持    5.5.14
  ENABLED_LOCAL_INFILE 是否启用本地 LOAD DATA INFILEOFF   5.5.7
  ENABLED_PROFILING 是否启用代码查询分析  ON   5.5.7
  INSTALL_BINDIR  MySQL 主执行文件目录 PREFIX/bin  5.5.7
  INSTALL_DOCDIR  文档安装路径  PREFIX/docs  5.5.7
  INSTALL_DOCREADMEDIR 自述文件目录  PREFIX   5.5.7
  INSTALL_INCLUDEDIR 头文件目录  PREFIX/include  5.5.7
  INSTALL_INFODIR  关于信息文件目录  PREFIX/docs 5.5.7
  INSTALL_LAYOUT  选择预定义的安装  STANDALONE 5.5.7
  INSTALL_LIBDIR  库文件目录   PREFIX/lib 5.5.7
  INSTALL_MANDIR  手册页面目录  PREFIX/man  5.5.7
  INSTALL_MYSQLSHAREDIR 共享数据目录  PREFIX/share  5.5.7
  INSTALL_MYSQLTESTDIR mysql-test 目录  PREFIX/mysql-test 5.5.7
  INSTALL_PLUGINDIR 插件目录   PREFIX/lib/plugin5.5.7
  INSTALL_SBINDIR  服务器超级用户执行文件目录 PREFIX/bin 5.5.7
  INSTALL_SCRIPTDIR 脚本目录   PREFIX/scripts 5.5.7
  INSTALL_SHAREDIR aclocal/mysql.m4 安装目录PREFIX/share  5.5.7
  INSTALL_SQLBENCHDIR sql-bench 性能测试工具目录PREFIX   5.5.7
  INSTALL_SUPPORTFILESDIR 扩展支持文件目录 PREFIX/support-files 5.5.7
  MYSQL_DATADIR  数据库存放目录     5.5.7
  MYSQL_MAINTAINER_MODE 是否启用MySQL的维护环境  OFF   5.5.7
  MYSQL_TCP_PORT  TCP/IP 端口号  3306   5.5.7
  MYSQL_UNIX_ADDR  Unix Socket 套接字文件 /tmp/mysql.sock  5.5.7
  SYSCONFDIR  选项配置文件目录     5.5.7
  WITH_COMMENT  编译环境发表评论    5.5.7
  WITH_DEBUG  是否包括调试支持  OFF   5.5.7
  WITH_EMBEDDED_SERVER 是否要建立嵌入式服务器  OFF  5.5.7
  WITH_xxx_STORAGE_ENGINE 静态编译xxx 存储引擎到服务器    5.5.7
  WITH_EXTRA_CHARSETS 额外的字符集,包括  all  5.5.7
  WITH_LIBWRAP  是否包括支持libwrap(TCP包装) OFF   5.5.7
  WITH_READLINE  使用捆绑的readline  OFF  5.5.7
  WITH_SSL  是否支持SSL  no   5.5.7
  WITH_ZLIB  是否支持Zlib  system   5.5.7
  WITHOUT_xxx_


运维网声明 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-602969-1-1.html 上篇帖子: MYSQL成绩排名 下篇帖子: mysql之mysql安装、初始化,以及mysql相关命令的使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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