MySQL Master-Slave Current Database

Hi all,
I created master slave replication on two servers. The existing databases on the master are not available on the slave. However, when a new database is created on the master, the slave is also created instantly.

When master-slave replication is created, why are the existing databases not in the slave?

During the creation of replica you missed to restore the master database and executed change master to master command to start replica. Also you not posted the details steps how you configured the master slave so its hard to tell where you miss the things.

1 Like

@parttime Please visit this How to setup a replica for replication in 6 simple steps with Percona XtraBackup - Percona XtraBackup, it help you understand how to configure a replica from the source server

1 Like

I am using below config.
Existing databases do not sync. even the slave does not have available databases in the master.
master
symbolic-links=0

bind-address=0.0.0.0
server-id = 1
#log_bin =mysql-bin
log-bin = /var/lib/mysql/mysql-bin.log

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

slave
symbolic-links=0

bind-address = 0.0.0.0
server-id = 2
#log_bin =mysql-bin

log-bin = /var/lib/mysql/mysql-bin.log

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

hi,
when ı run this script($ xtrabackup --backup --user=yourDBuser --password=MaGiCdB1 --target-dir=/var/lib/mysql), ı get this error. How can ı this error?

error;
xtrabackup: Can’t create/write to file ‘/var/lib/mysql/ibdata1’ (Errcode: 17 - File exists)

As a security mesure, you can’t restore a backup on a directory that already contains database files. Make sure that perform the restore on an empty directory.

thank you for respond.
But ı wan to create replication as master-slave. How can ı create a master slave without using percona?

You can create a replica (slave) using Percona Xtrabackup, just make sure that the replica (slave) directory where you restore the database is empty.

Follow the steps from this post:

this process only be done on the slave server?
Additionally, how can I create a master slave without using percona xtrabackup?

Using Percona XtraBackup:

  • follow the steps from the document linked previously.

Using MySQL dump or raw datafiles:

I hope this helps.

1 Like

hi again,
I traded with xtrabackup. When I want to open mysqld services in replica, I get the following error. How can I solve it?

[root@mac# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code.
See “systemctl status mysqld.service” and “journalctl -xe” for details.
[root@mac]#

2023-07-05T05:38:18.445896Z 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
2023-07-05T05:38:18.445915Z 0 [ERROR] InnoDB: Trying to access page number 3194822532 in space 0, space name innodb_system, which is outside the tablespace bounds. Byte offset 0, len 16384, i/o type read. If you get this error at mysqld startup, please check that your my.cnf matches the ibdata files that you have in the MySQL server.
2023-07-05T05:38:18.445920Z 0 [ERROR] InnoDB: Server exits.