[root@hanfeng ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
server_id = 130
log_bin=hf123
# 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
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# 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
保存退出
[root@hanfeng ~]# /etc/init.d/mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL.. SUCCESS!
[root@hanfeng ~]#
[root@hanfeng ~]# ls -lt /data/mysql/
总用量 110728
-rw-rw----. 1 mysql mysql 50331648 1月 19 23:35 ib_logfile0
-rw-rw----. 1 mysql mysql 12582912 1月 19 23:35 ibdata1
-rw-rw----. 1 mysql mysql 104317 1月 19 23:35 hanfeng.err
-rw-rw----. 1 mysql mysql 5 1月 19 23:35 hanfeng.pid
-rw-rw----. 1 mysql mysql 15 1月 19 23:35 hf123.index
-rw-rw----. 1 mysql mysql 120 1月 19 23:35 hf123.000001
drwx------. 2 mysql mysql 4096 1月 19 20:58 zrlog
-rw-rw----. 1 mysql mysql 56 1月 2 22:41 auto.cnf
drwx------. 2 mysql mysql 4096 1月 2 22:28 mysql
drwx------. 2 mysql mysql 4096 1月 2 22:28 performance_schema
-rw-rw----. 1 mysql mysql 50331648 1月 2 22:28 ib_logfile1
drwx------. 2 mysql mysql 6 1月 2 22:26 test
[root@hanfeng ~]#
[root@hanfeng ~]# mysqldump -uroot -phanfeng zrlog > /tmp/zrlog.sql
Warning: Using a password on the command line interface can be insecure.
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -phanfeng -e "create database han"
Warning: Using a password on the command line interface can be insecure.
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -phanfeng han < /tmp/zrlog.sql
Warning: Using a password on the command line interface can be insecure.
[root@hanfeng ~]#
[root@hanfeng ~]# ls -lt /data/mysql/
总用量 110740
-rw-rw----. 1 mysql mysql 50331648 1月 19 23:40 ib_logfile0
-rw-rw----. 1 mysql mysql 12582912 1月 19 23:40 ibdata1
-rw-rw----. 1 mysql mysql 10337 1月 19 23:40 hf123.000001
drwx------. 2 mysql mysql 4096 1月 19 23:40 han
-rw-rw----. 1 mysql mysql 104317 1月 19 23:35 hanfeng.err
-rw-rw----. 1 mysql mysql 5 1月 19 23:35 hanfeng.pid
-rw-rw----. 1 mysql mysql 15 1月 19 23:35 hf123.index
drwx------. 2 mysql mysql 4096 1月 19 20:58 zrlog
-rw-rw----. 1 mysql mysql 56 1月 2 22:41 auto.cnf
drwx------. 2 mysql mysql 4096 1月 2 22:28 mysql
drwx------. 2 mysql mysql 4096 1月 2 22:28 performance_schema
-rw-rw----. 1 mysql mysql 50331648 1月 2 22:28 ib_logfile1
drwx------. 2 mysql mysql 6 1月 2 22:26 test
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -phanfeng
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 194
Server version: 5.6.35-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> grant replication slave on *.* to 'repl'@'192.168.202.131' identified by 'hanfeng';
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> show master status;
+--------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+--------------+----------+--------------+------------------+-------------------+
| hf123.000001 | 10549 | | | |
+--------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> quit
Bye
[root@hanfeng ~]# ls /data/mysql
auto.cnf hanfeng.err hf123.000001 ibdata1 ib_logfile1 performance_schema zrlog
han hanfeng.pid hf123.index ib_logfile0 mysql test
[root@hanfeng ~]#
[root@hanfeng ~]# mysqldump -uroot -phanfeng test > /tmp/test.sql
Warning: Using a password on the command line interface can be insecure.
[root@hanfeng ~]#
[root@hanfeng ~]# ls /tmp/*sql
/tmp/test.sql /tmp/zrlog.sql
[root@hanfeng ~]#