zoukankan      html  css  js  c++  java
  • MySQL的启动方式

    MySQL常用启动方式:

    windows 和linux 上都可以使用 mysql --help|grep my.cnf 过滤查看关于MySQL对应 配置文件my.cnf 

    [root@bqh-118 bin]# mysql --help|grep my.cnf
    order of preference, my.cnf, $MYSQL_TCP_PORT,
    /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

    因我MySQL安装在/application目录下:

    1、mysqld_safe
    [root@bqh-118 /]# /application/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=root &
    客户端连接:
    mysql --defaults-file=/etc/my.cnf or mysql -S /tm/mysql.sock
     
    2、mysql.server

    [root@bqh-118 mysql]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server #将默认路径替换成自定义安装路径
    [root@bqh-118 mysql]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld  #将生成的启动脚本拷贝到init.d目录下
    [root@bqh-118 mysql]# chmod +x /etc/init.d/mysqld  #授予可执行权限
    [root@bqh-118 mysql]# lsof -i:3306  #查询mysql服务是否开启

    [root@bqh-118 mysql]# /etc/init.d/mysqld start
    Starting MySQL.. SUCCESS!

    启动mysql服务器:service mysql.server {start|stop|restart|reload|force-reload|status}

    当然也可以让chkconfig来管理

    客户端连接:
    mysql --defaults-file=/etc/my.cnf or mysql -S /tm/mysql.sock
     
    3、多实例mysqld_multi
    mkdir $MYSQL_BASE/data2
    cat <<-EOF>> /etc/my.cnf
    [mysqld_multi]
    mysqld = /application/mysql/bin/mysqld_safe
    mysqladmin = /application/mysql/bin/mysqladmin
    user = mysqladmin
    password = mysqladmin
     
    [mysqld3306]
    port            = 3306
    socket          = /tmp/mysql3306.sock
    pid-file = /tmp/mysql3306.pid
    skip-external-locking
    key_buffer_size = 16M
    max_allowed_packet = 1M
    table_open_cache = 64
    sort_buffer_size = 512K
    net_buffer_length = 8K
    read_buffer_size = 256K
    read_rnd_buffer_size = 512K
    myisam_sort_buffer_size = 8M
    basedir = /application/mysql
    datadir = /application/mysql/data
     
    [mysqld3307]
    port            = 3307
    socket          = /tmp/mysql3307.sock
    pid-file = /tmp/mysql3307.pid
    skip-external-locking
    key_buffer_size = 16M
    max_allowed_packet = 1M
    table_open_cache = 64
    sort_buffer_size = 512K
    net_buffer_length = 8K
    read_buffer_size = 256K
    read_rnd_buffer_size = 512K
    myisam_sort_buffer_size = 8M
    basedir = /application/mysql
    datadir = /application/mysql/data2
    EOF
     
    #mysql -S /tmp/mysql3306.sock
    mysql>GRANT SHUTDOWN ON *.* TO 'mysqladmin'@'localhost' identified by 'mysqladmin' with grant option;
     
    #mysql -S /tmp/mysql3307.sock
    mysql>GRANT SHUTDOWN ON *.* TO 'mysqladmin'@'localhost' identified by 'mysqladmin' with grant option;
     
    启动mysql服务器:/application/mysql/bin/mysqld_multi --defaults-file=/etc/my.cnf start 3306-3307
    关闭mysql服务器:/application/mysql/bin/mysqladmin shutdown
     
    当然,也可以写脚本一键启动的。
     
  • 相关阅读:
    centos8 将SSSD配置为使用LDAP并要求TLS身份验证
    Centos8 搭建 kafka2.8 .net5 简单使用kafka
    .net core 3.1 ActionFilter 拦截器 偶然 OnActionExecuting 中HttpContext.Session.Id 为空字符串 的问题
    Springboot根据不同环境加载对应的配置
    VMware Workstation12 安装 Centos8.3
    .net core json配置文件小结
    springboot mybatisplus createtime和updatetime自动填充
    .net core autofac依赖注入简洁版
    .Net Core 使用 redis 存储 session
    .Net Core 接入 RocketMQ
  • 原文地址:https://www.cnblogs.com/su-root/p/10887972.html
Copyright © 2011-2022 走看看