zoukankan      html  css  js  c++  java
  • Linux源码安装mysql步骤

    创建文件夹:
     mkdir  /usr/local/webserver
     安装必要依赖包
          yum -y install gcc gcc-c++ make ncurses-devel
    安装cmake包:
        tar zxvf cmake-2.8.12.2.tar.gz
        cd cmake-2.8.12.2
        ./bootstrap --prefix="/usr/local/webserver/cmake"  
        make && make install
    源码安装ncurses:
       
        tar zxvf ncurses-5.9.tar.gz
        cd ncurses-5.9
        ./configure --prefix="/usr/local/webserver/ncurses" 
        make && make install
    安装mysql源码(参数根据自己的配置来填写):
    tar zxvf mysql-5.6.17.tar.gz 
        cd  mysql-5.6.17
    /usr/local/webserver/cmake/bin/cmake .
            -DCMAKE_INSTALL_PREFIX="/usr/local/webserver/mysql"
            -DMYSQL_DATADIR="/usr/local/webserver/mysql/data"
            -DMYSQL_UNIX_ADDR="/usr/local/webserver/mysql/data/mysql.sock"
            -DMYSQL_TCP_PORT="3306"
            -DDEFAULT_CHARSET=utf8
            -DDEFAULT_COLLATION=utf8_general_ci
            -DWITH_EXTRA_CHARSETS=all
            -DENABLED_LOCAL_INFILE=1
            -DWITH_INNOBASE_STORAGE_ENGINE=1 
        make && make install
    #mysql初始化(my.cnf可根据自己的配置进行修改)
    my.cnf
    [client]
    port=3306
    socket=/usr/local/webserver/mysql/data/mysql.sock
     
    [mysqld]
    port=3306
    basedir=/usr/local/webserver/mysql
    datadir=/usr/local/webserver/mysql/data
    socket=/usr/local/webserver/mysql/data/mysql.sock
    user=mysql
    default-time-zone=system
    character-set-server=utf8
    default-storage-engine=InnoDB
    #cp mysqlmysql-5.6.17/my.cnf /usr/local/webserver/mysql/
            cd /usr/local/webserver/mysql/ 
            chown -R mysql:mysql . 
            ./scripts/mysql_install_db
                --basedir="/usr/local/webserver/mysql"
                --datadir="/usr/local/webserver/mysql/data"
                --user=mysql
            #目录权限
            cd  /usr/local/webserver/mysql/ 
            chown -R root . 
            chown -R mysql data
            #删除多余文件和目录
            cd  /usr/local/webserver/mysql/ 
    rm -rf COPYING README INSTALL-BINARY docs man
            #设置开机自动启动mysql
    cp  mysql-5.6.17/support-files/mysql.server /etc/init.d/mysqld
            chmod +x /etc/init.d/mysqld
            chkconfig --add mysqld
            chkconfig mysqld on
    ****
            #启动mysql
            service mysqld start
      启动报错:

      Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

      解决方案:清理data数据目录中的全部数据,然后从新初始化mysql:/scripts/mysql_install_db

            #访问权限设置
            /usr/local/webserver/mysql/bin/mysqladmin -uroot password "12344"
            /usr/local/webserver/mysql/bin/mysql -uroot -p123456  
    grant all privileges on *.* to 'root'@'%' identified by '123456';


            #执行mysql_secure_installation进行优化
            cd /usr/local/webserver/mysql/ 
    ./bin/mysql_secure_installation
    注(按照自身的需要来选择):
    输入密码进入选择
    Change the root password? [Y/n]
    Remove anonymous users? [Y/n]
    Disallow root login remotely? [Y/n]
    Remove test database and access to it? [Y/n]
    Reload privilege tables now? [Y/n]

  • 相关阅读:
    为什么有时候程序出问题会打印出“烫烫烫烫...
    VC++共享数据段实现进程之间共享数据
    IEEE浮点数float、double的存储结构
    前端智勇大闯关
    Python:高级主题之(属性取值和赋值过程、属性描述符、装饰器)
    来认识下less css
    Koala Framework
    在使用Kettle的集群排序中 Carte的设定——(基于Windows)
    标准库类型
    iOS多线程的初步研究1
  • 原文地址:https://www.cnblogs.com/byteworld/p/5691417.html
Copyright © 2011-2022 走看看