我在centos7的2 mysql8.0之间设置了主从模式。 我有一个关于master alrealdy的数据库,其中有一些表和数据。 但是,当我启动从服务器时,显示从服务器状态\ G,我得到Last_Error:执行行事件时出错:“未知数据库”错误。
master my.cnf:
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
max_connections = 1000
lower_case_table_names = 1
log_bin_trust_function_creators=1
log_bin_trust_function_creators=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
transaction_isolation = READ-COMMITTED
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id=1
innodb_flush_log_at_trx_commit=2
sync_binlog=0
log-bin=/home/mysql/logs/bin-log/master-bin
log-bin-index=/home/mysql/logs/bin-log/master-bin.index
max_binlog_size = 500M
log-slave-updates
binlog_format="MIXED"
从属配置:
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
max_connections = 1000
lower_case_table_names = 1
log_bin_trust_function_creators=1
log_bin_trust_function_creators=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
transaction_isolation = READ-COMMITTED
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id=2
innodb_flush_log_at_trx_commit=2
sync_binlog=0
log-bin=/home/mysql/logs/bin-log/slave-bin
错误:
Last_SQL_Errno: 1049
Last_SQL_Error: Error executing row event: 'Unknown database 'db''
如果我通过my.cnf:
...
slave_skip_errors=1049
一切正常,但从属节点没有数据库'db'。
问题是我需要数据库'db',并且我希望它自动同步主数据库'db'中的数据。
如果我想让mysql每晚自动自动同步数据,该如何设置同步时间?