首页 > 数据库 > MySQL > mysql 启动和停止
mysql 启动方法
1.mysqld
mysqld is the mysql server
mysqld reads options from the [mysqld] and [server] groups
we can invoke mysqld manually. this is usually not done except for debugging purposes.
if you invoke the server this way,error messages go to the terminal by default rather than to error log
--connection
start
./libexec/mysqld --defaults-file=./my.cnf --user=mysql
connect
mysql --defaults-file=./my.cnf
mysql -S /tmp/mysql.sock
mysqld --defaults-file=my.cnf --user=mysql
2. mysqld_safe
mysqld_safe reads all options from the [mysqld],[server], and [mysqld_safe] sections in option
files.For backward compatibility,is also reads [safe_mysqld] sections,although you should rename
such sections to [mysqld_safe] in mysql 5.1 installations
mysqld_safe is a shell script that invokes mysqld.the script sets up the error log,and then launches
mysqld and monitors it .If mysqld terminates abnormally,mysql_sadr restarts it.
connect
-- start
mysqld_safe --defaults-file=./my.cnf --user=mysql &
--connect
mysqld -defaults-file=./my.cnf
mysql -S /tmp/mysql.sock
3.mysql.server
mysql distributions on unix include a script named mysql.server.it can be used on
system such as linux and solaris that system v-style run diectories to start and stop
system services.it is also used by max os x startup item for mysql
$mysql_base/share/mysql/mysql.server and support-files/mysql.server
mysql.server reads options from the [mysql.server] and [mysqld] sections of options files.
for backward compatibility,it also reads [mysql_server] sections,although you should rename
such sections to [mysql.server] when using mysql 5.1
a shell script that invokes mysqld_safe
4.mysql_multi启动
mysql_multi is designed to manage several mysqld processes that listen for connections on different Unix socket files and tcp/ip ports.
it can start or stop servers ,report their current status.the mysql isntance manager is an alternative means of managing multiple
servers
--hot to config
1. mkdir $mysql_base/data2
2.mysql_install_db --basedir=$mysql_base --datair=$mysql_base/data2 --user=mysql
3 vi $mysql_base/my.cnf
[mysqld_multi]
mysqld=/opt/mysql/bin/mysqld_safe
mysqladmin=/opt/mysql/bin/mysqladmin
user=test
password=test
[client]
port =3306
socket = /tmp/mysql.sock
[mysqld3306]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
--
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin=11g-lrep-bin
# These are commonly set, remove the # and set as required.
basedir = /opt/mysql
datadir = /opt/mysql/data
port = 3306
# server_id = .....
socket =/tmp/mysql3306.sock
pid-file =/tmp/mysql3306.pid
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3307]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin=11g-lrep-bin
# These are commonly set, remove the # and set as required.
basedir = /opt/mysql
datadir = /opt/mysql/data2
port = 3307
# server_id = .....
socket =/tmp/mysql3307.sock
pid-file =/tmp/mysql3307.pid
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3308]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin=11g-lrep-bin
# These are commonly set, remove the # and set as required.
basedir = /opt/mysql
datadir = /opt/mysql/data3
port = 3308
# server_id = .....
socket =/tmp/mysql3308.sock
pid-file =/tmp/mysql3308.pid
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
4.mysqld_multi --defaults-file=./my.cnf start 3306
5.mysql -u root -P3306 --protocol=tcp
mysql -S /tmp/mysql3306.sock
日志位置
/opt/mysql/share/mysqld_multi.log
6.grant shutdown on *.* to 'test'@localhost identified by 'test' with grant option;
show grants for test@localhost;
mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
7.mysqld_multi --defaults-file=./my.cnf stop 3306
mysqld_multi --defaults-file=my.cnf stop 3307-3308
--连接mysql
communication protocols
protocol types of connections supported
tcp/ip
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24577884/viewspace-1063397/ ,如需转载,请注明出处,否则将追究法律责任。