• MySQL第01课- CentOS + 单实例MySql编译安装总结


    2016年2月,从oracle转向MySql ,碰上几个坑,特此记录

    总结

    1、注意环境变量、配置文件,操作过程不能出错

    2、相比rpm方式安装,编译安装方式可以指定安装路径,再说安装是简单活,将来安装最新版数据库,会看文档,学里面的知识更重要

    3、系统管理员操作数据库一定要小心,重要操作应三思而后行

    -----------------------------------------

    1、注意:第一步要检查是否有安装过mysql,有的话要干掉,否则最后启动服务不成功

    [root@fox ~]# rpm -qa|grep mysql
     mysql-libs-5.1.73-5.el6_6.x86_64    
    干掉之前安装的包 [root@fox
    ~]# rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64

     2、写成sh文件,放到操作系统上。执行,可以出去喝茶回来看结果

    cd /tools/
    tar xf cmake-2.8.8.tar.gz
    cd cmake-2.8.8
    ./configure
    #CMake has bootstrapped. Now run gmake.
    gmake
    gmake install
    cd ../
    #依赖包
    yum install ncurses-devel -y
    #创建用户和组
    groupadd mysql
    useradd mysql -s /sbin/nologin -M -g mysql
    mkdir -p /application/mysql-5.5.32/data
    mkdir -p /application/mysql-5.5.32/tmp
    #解压编译MySQL
    cd /tools/
    tar zxf mysql-5.5.32.tar.gz 
    cd mysql-5.5.32
    cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 
    -DMYSQL_DATADIR=/application/mysql-5.5.32/data 
    -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock 
    -DDEFAULT_CHARSET=utf8 
    -DDEFAULT_COLLATION=utf8_general_ci 
    -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii 
    -DENABLED_LOCAL_INFILE=ON 
    -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_FEDERATED_STORAGE_ENGINE=1 
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
    -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 
    -DWITHOUT_PARTITION_STORAGE_ENGINE=1 
    -DWITH_FAST_MUTEXES=1 
    -DWITH_ZLIB=bundled 
    -DENABLED_LOCAL_INFILE=1 
    -DWITH_READLINE=1 
    -DWITH_EMBEDDED_SERVER=1 
    -DWITH_DEBUG=0
    make
    #[100%] Built target my_safe_process
    make install
    ln -s /application/mysql-5.5.32/ /application/mysql
    chown -R mysql:mysql /application/mysql/
    chmod -R 1777 /tmp/
    cd /application/mysql/scripts/
    ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

     ------------------ 会出现如下

    Installing MySQL system tables...
    OK
    Filling help tables...
    OK

    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:

    /application/mysql//bin/mysqladmin -u root password 'new-password'
    /application/mysql//bin/mysqladmin -u root -h fox password 'new-password'

    Alternatively you can run:
    /application/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 /application/mysql/ ; /application/mysql//bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl
    cd /application/mysql//mysql-test ; perl mysql-test-run.pl

    Please report any problems with the /application/mysql//scripts/mysqlbug script!

    表示安装正常!

    3、配置my.cnf文件,环境变量,启动服务

    [root@fox tools]# cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
    [root@fox tools]# echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile
    [root@fox tools]# source /etc/profile
    [root@fox tools]# /bin/cp mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld 
    [root@fox tools]# chmod +x /etc/init.d/mysqld 
    [root@fox tools]# /etc/init.d/mysqld start
    Starting MySQL... [ OK ]
    [root@fox tools]# netstat -lnutp|grep 3306 
    tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 26343/mysqld 

    4、进入MySQL数据库 

    [root@fox tools]# mysql


  • 相关阅读:
    Linux用户和用户组管理
    Linux系统概述
    Linux LVM 配置
    linux too many open files 问题总结
    tidb初体验
    kafka配置内外网访问
    使用docker快速安装软件
    一次ssh不能登陆问题
    kubernetes集群证书更新
    istio之envoy常见术语及状态码
  • 原文地址:https://www.cnblogs.com/micfox/p/10556165.html
Copyright © 2020-2023  润新知