MySQL启动方式

根据小辉老师视频,暂列学习笔记


#1.mysqld
     mysqld is the MySQL server.
     mysqld reads options from the [mysqld] and [server] groups in my.cnf.
     If we invoke the server with mysqld manually, error messages go to the terminal by default ranther than to the error log.

     e.g. 
     start:           ./bin/mysqld --defaults-file=/etc/my.cnf --user=mysql
     connect:      mysql --defaults-file=/etc/my.cnf
                       mysql -S /var/lib/mysql/mysql.sock
     
#2.mysqld_safe
     reads [mysqld], [server], [mysqld_safe] and [safe_mysqld] sections.
     mysql_safe is a shell script that invokes mysqld, it sets up the error log, and then launches mysqld and monitors it. If mysqld terminates abnormally, mysql_safe restarts it.
     
     ./mysqld_safe --defaults-file=/etc/my.cnf --user=mysql&

#3.mysql.server
     support-files/mysql.server
     reads [mysql.server], [mysqld] and [mysql_server].
     
     ./mysql.server --help
     #####封装成系统服务的形式###########
     cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
     chkconfig -add mysql
     service mysql start(用service的形式启动)

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/mysql5152/etc/my.cnf ~/.my.cnf, will be override by the later one.

停止方法
     mysqladmin shutdown(需要相应的权限)

#4.mysqld_multi
     mysqld_multi is designed to manage serveral mysqld processes that listen for connections on different Unix socket files and TCP/IP ports. It can start or stop servers, or report their current status. The MySQL Instance Manager is an alternative means of managing mutilple servers.
     
     How to config
     1.      mkdir $MySQL_BASE/data2
     2.      mysql_install_db --basedir=$mysql_base --datadir=$mysql_base/data2 --user=mysql
     3.      vi $MySQL_BASE/my.cnf
               [mysqld_multi]
               mysqld=/u01/mysql/bin/mysqld_safe
               mysqladmin=/u01/mysql/bin/mysqladmin
               user=test
               password=test
     4.      ./bin/mysqld_multi --defaults-file=./my.cnf start 3306
     5.      mysql -S ./mysql3306.sock -u root
              grant shutdown on *.* to 'test'@'localhost' identified by 'test' with grant option;
              show grants for root@localhost;
              ./bin/mysqld_multi --defaults-file=./my.cnf start 3306-3308

my.cnf

socket=/tmp/mysql3306.sock
pid-file=/tmp/mysql3306.pid
#skip-locking
key_buffer_size=16K
max_allowed_packet=1M
table_open_cache=4
sort_buffer_size=64K
read_buffer_size=256K
read_rnd_buffer_size=256K
net_buffer_length=2K
thread_stack=128K
basedir=/u01/mysql
datadir=/u01/mysql/data
server_id=1


[mysqld3307]
port=3307
socket=/tmp/mysql3307.sock
pid-file=/tmp/mysql3307.pid
#skip-locking
key_buffer_size=16K
max_allowed_packet=1M
table_open_cache=4
sort_buffer_size=64K
read_buffer_size=256K
read_rnd_buffer_size=256K
net_buffer_length=2K
thread_stack=128K
basedir=/u01/mysql
datadir=/u01/mysql/data2
server_id=1


[mysqld3308]
port=3308
socket=/tmp/mysql3308.sock
pid-file=/tmp/mysql3308.pid
#skip-locking
key_buffer_size=16K
max_allowed_packet=1M
table_open_cache=4
sort_buffer_size=64K
read_buffer_size=256K
read_rnd_buffer_size=256K
net_buffer_length=2K
thread_stack=128K
basedir=/u01/mysql
datadir=/u01/mysql/data3
server_id=1


[client]
#password=your_password
port=3306
socket=/var/lib/mysql/mysql.sock

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值