• 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
     
    当然,也可以写脚本一键启动的。
     
  • 相关阅读:
    DS博客作业05--查找
    DS博客作业04--图
    DS博客作业03--树
    DS博客作业02--栈和队列
    DS博客作业02--线性表
    c博客06-结构体&文件
    C博客作业05--2019-指针
    面向对象设计大作业——QQ联系人系统
    DS博客作业05--查找
    DS博客作业04--图
  • 原文地址:https://www.cnblogs.com/su-root/p/10887972.html
Copyright © 2020-2023  润新知