Cmake MySQL5.6 编译安装

时间:2022-08-16 17:20:54


进入MySQL5.5以后,MySQL的安装都变成了用Cmake来安装了。

一:准备工作

    cd /usr/local/src/

    在当前目录下准备好安装包,

    cmake-3.0.2.tar.gz  下载

    mysql-5.6.20.tar.gz  下载


二:安装

    #cmake
    tar -zxvf cmake-3.0.2.tar.gz
    cd cmake-3.0.2
    ./bootstrap
    gmake
    gmake install


    #mysql
    tar zxvf mysql-5.6.20.tar.gz  
    cd mysql-5.6.20 
    cmake \  
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  
    -DMYSQL_DATADIR=/usr/local/mysql/data \  
    -DSYSCONFDIR=/etc \  
    -DWITH_MYISAM_STORAGE_ENGINE=1 \  
    -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 
    -DWITH_PARTITION_STORAGE_ENGINE=1 \
    -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \  
    -DMYSQL_TCP_PORT=3306 \  
    -DENABLED_LOCAL_INFILE=1 \  
    -DEXTRA_CHARSETS=all \  
    -DDEFAULT_CHARSET=utf8 \  
    -DDEFAULT_COLLATION=utf8_general_ci

    详细参数请查看官网说明,地址

    make && make install
    #生成配置文件
    cd support-files
    cp my-default.cnf /etc/my.cnf


    groupadd mysql  
    useradd -M -s /sbin/nologin -g mysql mysql  
    chown -R mysql:mysql /usr/local/mysql  
    cd /usr/local/mysql
    #初始化数据库
    scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql


    #添加服务,拷贝服务脚本到init.d目录,并设置开机启动  
    cp support-files/mysql.server /etc/init.d/mysqld  
    chkconfig mysqld on  
    #启动MySQL  
    service mysqld start


    #更改密码
    /usr/local/mysql/bin/mysqladmin -u root password 123456
    #测试连接mysql
    /usr/local/mysql/bin/mysql -u root -p


    修改/etc/profile文件,在文件末尾添加  
    vi /etc/profile  
    PATH=/usr/local/mysql/bin:$PATH  
    export PATH  

    source /etc/profile


    #修改密码  
    mysql -uroot  
    mysql> SET PASSWORD = PASSWORD('123456');  
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;


   

Directory Contents of Directory
bin, scripts mysqld server, client and utility programs
data Log files, databases
docs MySQL manual in Info format
man Unix manual pages
include Include (header) files
lib Libraries
share Miscellaneous support files, including error messages, sample configuration files, SQL for database installation
sql-bench Benchmarks