• msyql 二进制安装(自定义安装目录)


    2.二进制安装(自定义安装目录)

    1)上传包

    [root@db03 ~]# rz
    

    2)安装依赖

    [root@db03 ~]# yum install -y ncurses-devel libaio-devel cmake glibc autoconf gcc-c++
    

    3)解压

    [root@db03 ~]# tar xf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz
    

    4)创建自定义目录

    [root@db03 ~]# mkdir /service
    

    5)移动并改名

    [root@db03 ~]# mv mysql-5.6.42-linux-glibc2.12-x86_64 /service/mysql-5.6.42
    

    6)做软连接

    [root@db03 ~]# ln -s /service/mysql-5.6.42 /service/mysql
    

    7)创建用户

    [root@db03 ~]# useradd mysql -s /sbin/nologin -M
    

    8)拷贝启动文件和配置文件

    [root@db03 ~]# cd /service/mysql/support-files/
    [root@db03 /service/mysql/support-files]# cp my-default.cnf /etc/my.cnf
    cp: overwrite '/etc/my.cnf'? y
    [root@db03 /service/mysql/support-files]# cp mysql.server /etc/init.d/mysqld
    

    9)初始化

    [root@db03 ~]# cd /service/mysql/scripts/
    [root@db03 /service/mysql/scripts]# ./mysql_install_db --user=mysql --basedir=/service/mysql --datadir=/service/mysql/data
    

    10)配置system管理启动MySQL

    [root@db03 ~]# vim /usr/lib/systemd/system/mysqld.service
    [Unit]
    Description=MySQL Server
    Documentation=man:mysqld(8)
    Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
    After=network.target
    After=syslog.target
    [Install]
    WantedBy=multi-user.target
    [Service]
    User=mysql
    Group=mysql
    ExecStart=/service/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
    LimitNOFILE = 5000
    
    [root@db03 ~]# systemctl daemon-reload
    

    11)启动数据库

    #1.使用system启动
    [root@db03 ~]# systemctl start mysqld
    	#查看进程启动失败,没有任何报错
    
    #2.使用mysqld启动脚本启动
    [root@db03 ~]# /etc/init.d/mysqld start
    /etc/init.d/mysqld: line 244: my_print_defaults: command not found
    /etc/init.d/mysqld: line 264: cd: /usr/local/mysql: No such file or directory
    Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
    	#原因:二进制的包是源码包已经生成编译安装完成的,在cmake阶段已经指定了所有的目录都是/usr/local/mysql,所以启动时所有程序都去找/usr/local/mysql目录,没有该目录,所以启动失败
    	
    #3.解决启动问题
    	1)方法一:做软连接
    	[root@db03 ~]# ln -s /service/mysql /usr/local/mysql
    	
    	2)方法二:修改启动文件
    	[root@db03 ~]# vim /etc/init.d/mysqld 
    	basedir=/service/mysql
    	datadir=/service/mysql/data
    	
    #4.再次测试启动
    [root@db03 ~]# /etc/init.d/mysqld start
    Starting MySQL. SUCCESS!
    #或者
    [root@db03 ~]# systemctl start mysqld
    

    12)设置环境变量

    [root@db02 ~]# vim /etc/profile.d/mysql.sh
    export PATH=/service/mysql/bin:$PATH
    
    [root@db02 ~]# source /etc/profile
    
  • 相关阅读:
    win查看所有wifi密码
    vsftp配置详解
    python3.7项目打包为一个exe
    ATT&CK实战系列——红队实战(一)
    PHP SECURITY CALENDAR 2017 (Day 9
    python3安装gmpy2
    [CISCN2019 总决赛 Day2 Web1]Easyweb(预期解)
    python2与python3共存及py2IDLE打不开的解决方案
    [BJDCTF 2nd]
    PHP SECURITY CALENDAR 2017 (Day 1
  • 原文地址:https://www.cnblogs.com/xiaolang666/p/13846570.html
Copyright © 2020-2023  润新知