zoukankan      html  css  js  c++  java
  • 源码安装mysql-5.5.22

    准备

    mysql5.5需要使用cmake安装

    下载:

    cmake-3.2.2-Linux-x86_64.tar.gz

    解压

    tar -zxvf cmake-3.2.2-Linux-x86_64.tar.gz 

    1、创建mysql用户

    groupadd mysql
    useradd -g mysql mysql
    

    2、目录创建

    mkdir -p /opt/mysql
    chown -R mysql:mysql /opt/mysql
    
    cd /opt/mysql
    mkdir data
    mkdir etc
    

      

    3、解压安装包

    tar -zxvf mysql-5.5.22.tar.gz 
    

      

    4、编译

    ../cmake-3.2.2-Linux-x86_64/bin/cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/opt/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
    
    
    make
    
    
    make install
    

      

    5、初始化数据库

    cd /opt/mysql/scripts
    chmod +x mysql_install_db
    ./mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data --user=mysql
    

      

      

    6、设置mysql开机启动

    cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql
    chmod 755 /etc/init.d/mysql
    

      

    7、配置环境变量

    /etc/profile
    export PATH=/opt/mysql/bin:$PATH
    

      

    8、启动mysql

    /etc/init.d/mysql start
    mysql -u root -p
    

      

    9、重启、关闭

    /etc/init.d/mysql restart
    /etc/init.d/mysql stop
    

      

    10、设置root密码

    /opt/mysql/bin/mysqladmin -u root password mysql

    11、登录mysql

    mysql -u root -p
    
    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | test |
    +--------------------+
    4 rows in set (0.02 sec)

    12权限

    使其他主机能够通过root用户连接

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION;

    13修改字符集

    ALTER DATABASE form DEFAULT CHARACTER SET = gbk; 

    14创建数据库

    CREATE DATABASE forum DEFAULT CHARACTER SET   gbk;
  • 相关阅读:
    中国剩余定理
    【BZOJ】【3053】The Closest M Points
    【BZOJ】【1878】【SDOI2009】HH的项链
    【BZOJ】【2648】SJY摆棋子&【BZOJ】【2716】【Violet 3】天使玩偶
    【UOJ Easy Round #2】
    【TYVJ 五月图论专项有奖比赛】
    【BZOJ】【3301】【USACO2011 Feb】Cow Line
    【BestCoder】【Round#41】
    【BZOJ】【1046】/【POJ】【3613】【USACO 2007 Nov】Cow Relays 奶牛接力跑
    【BZOJ】【3210】花神的浇花集会
  • 原文地址:https://www.cnblogs.com/huanhuanang/p/4923321.html
Copyright © 2011-2022 走看看