zoukankan      html  css  js  c++  java
  • Linux 安装mysql

    安装编译源码所需的工具和库 准备

    yum install gcc gcc-c++ ncurses-devel perl 
    

     安装cmake

    wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz 
    tar zxvf cmake-2.8.10.2.tar.gz cmake
    cd cmake
    ./configure
    make
    make install
    cmake -version
    
    -DCMAKE_INSTALL_PREFIX=dir_name     设置mysql安装目录
    -DMYSQL_UNIX_ADDR=file_name     设置监听套接字路径,这必须是一个绝对路径名。默认为/tmp/mysql.sock
    -DDEFAULT_CHARSET=charset_name     设置服务器的字符集。
    缺省情况下,MySQL使用latin1的(CP1252西欧)字符集。cmake/character_sets.cmake文件包含允许的字符集名称列表。
    -DDEFAULT_COLLATION=collation_name     设置服务器的排序规则。
    -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_ARCHIVE_STORAGE_ENGINE=1
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
    -DWITH_PERFSCHEMA_STORAGE_ENGINE=1     存储引擎选项:
    
    MyISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。
    
    静态编译一个存储引擎到服务器,使用-DWITH_engine_STORAGE_ENGINE= 1
    
    可用的存储引擎值有:ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), 和PERFSCHEMA (Performance Schema)
    -DMYSQL_DATADIR=dir_name     设置mysql数据库文件目录
    -DMYSQL_TCP_PORT=port_num     设置mysql服务器监听端口,默认为3306
    -DENABLE_DOWNLOADS=bool     是否要下载可选的文件。例如,启用此选项(设置为1),cmake将下载谷歌所使用的测试套件运行单元测试。

    创建mysql 安装目录

    [root@iZgahlk1l73998Z cmake]# mkdir -p /usr/local/webserver/mysql
    [root@iZgahlk1l73998Z cmake]# mkdir -p /usr/local/webserver/mysql/data
    

     添加mysql 用户和组

    groupadd mysql  
    useradd -r -g mysql mysql 
    

     设置目录用户

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

    下载 mysql source code  采用的是源码包安装  还有rpm

    [root@iZgahlk1l73998Z src]# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37.tar.gz
    [root@iZgahlk1l73998Z src]# tar zxvf mysql-5.6.37.tar.gz
    

    查看mysql目录文件下所有文件(查看是为了之前安装Linux generic 报错 CMake  CMakeCache.txt) OK 这个有 就是你下载的版本不对  出错详情可查看http://www.cnblogs.com/buxiangxin/p/7217572.html

    [root@iZgahlk1l73998Z mysql-5.6.37]# ls
    BUILD           cmake_install.cmake  COPYING                  Docs                 INSTALL      make_dist.cmake  mysys_ssl  scripts           storage        VERSION
    client          CMakeLists.txt       CPackConfig.cmake        Doxyfile-perfschema  libevent     Makefile         packaging  source_downloads  strings        VERSION.dep
    cmake           cmd-line-utils       CPackSourceConfig.cmake  extra                libmysql     man              plugin     sql               support-files  vio
    CMakeCache.txt  config.h.cmake       CTestTestfile.cmake      include              libmysqld    mysql-test       README     sql-bench         tests          win
    CMakeFiles      configure.cmake      dbug                     info_macros.cmake    libservices  mysys            regex      sql-common        unittest       zlib
    [root@iZgahlk1l73998Z mysql-5.6.37]# 
    

    cmake mysql 安装

    [root@iZgahlk1l73998Z mysql-5.6.37]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ 
    -DMYSQL_UNIX_ADDR=/usr/local/webserver/mysql/mysql.sock  
    -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATTON=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_ARCHIVE_STORAGE_ENGINE=1 
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1
     -DMYSQL_DATADIR=/usr/local/webserver/mysql/data/mysqldb 
    -DMYSQL_TCP_PORT=3306
     -DENABLE_DOWNLOADS=1
    

     编译安装 时间比较长

    [root@iZgahlk1l73998Z mysql-5.6.37]# make
    [root@iZgahlk1l73998Z mysql-5.6.37]# make install
    

     修改数据库文件目录

    这里需要注意一点

    [root@iZgahlk1l73998Z data]# chown -R mysql:mysql ./
    [root@iZgahlk1l73998Z data]# ll
    total 4
    drwxr-xr-x 2 mysql mysql 4096 Jul 21 14:51 test
    

     现在开始初始化数据库 但是报错 看信息

    [root@iZgahlk1l73998Z mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/webserver/mysql/data/mysqldb/
    Installing MySQL system tables...2017-07-21 16:05:28 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2017-07-21 16:05:28 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
    2017-07-21 16:05:28 0 [Note] ./bin/mysqld (mysqld 5.6.37) starting as process 29642 ...
    2017-07-21 16:05:28 29642 [ERROR] COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'
    2017-07-21 16:05:28 29642 [ERROR] Aborting
    
    2017-07-21 16:05:28 29642 [Note] Binlog end
    2017-07-21 16:05:28 29642 [Note] ./bin/mysqld: Shutdown complete
    

     一个个解决 解决方案

    http://www.cnblogs.com/buxiangxin/p/7218652.html
    http://www.cnblogs.com/buxiangxin/p/7218631.html

    To start mysqld at boot time you have to copy
    support-files/mysql.server to 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 following commands:
    
      /usr/local/webserver/mysql//bin/mysqladmin -u root password 'new-password'
      /usr/local/webserver/mysql//bin/mysqladmin -u root -h iZgahlk1l73998Z password 'new-password'
    
    Alternatively you can run:
    
      /usr/local/webserver/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/webserver/mysql//bin/mysqld_safe &
    
    You can test the MySQL daemon with mysql-test-run.pl
    
      cd mysql-test ; perl mysql-test-run.pl
    
    Please report any problems at http://bugs.mysql.com/
    
    The latest information about MySQL is available on the web at
    
      http://www.mysql.com
    
    Support MySQL by buying support/licenses at http://shop.mysql.com
    
    WARNING: Found existing config file /usr/local/webserver/mysql//my.cnf on the system.
    Because this file might be in use, it was not replaced,
    but was used in bootstrap (unless you used --defaults-file)
    and when you later start the server.
    The new default config file was created as /usr/local/webserver/mysql//my-new.cnf,
    please compare it with your file and take the changes you need.
    

     OK

    创建启动脚本

  • 相关阅读:
    handsontable合并项mergeCells应用及扩展
    handsontable的基础应用
    overflow的使用
    阿里云服务器磁盘空间扩容步骤
    使用Gitblit 在Windows2008 r2上部署Git Server(完整版)
    搭建一个基于微信公众号的信息采集功能
    js数组内置方法
    C#数组、js数组、json
    将EF项目从dbfirst转化为codefirst
    通过HttpWebRequest调用webService
  • 原文地址:https://www.cnblogs.com/buxiangxin/p/7216826.html
Copyright © 2011-2022 走看看