设置 MySQL 复制?

发布于 2024-11-05 10:09:02 字数 1144 浏览 0 评论 0原文

更新:已编辑以将实际数据添加到数据库中,但仍然存在同样的问题。

我正在使用 Debian (6.0.1) 的普通安装和最新版本的 MySQL,并尝试设置 MySQL 数据库复制。

这就是我到目前为止所做的:

$ apt-get upgrade
$ apt-get install mysql-client mysql-server 
$ vi /etc/mysql/my.cnf
  # Comment out bind-addressb 
  # bind-address            = 127.0.0.1 
  # Add these lines
  log-bin = /var/log/mysql/mysql-bin.log
  binlog-do-db=exampledb
  server-id=1
$ /etc/init.d/mysql restart
$ mysql -u root -p
> CREATE DATABASE exampledb;
> USE exampledb;
> CREATE TABLE berries (name VARCHAR(100));
> INSERT INTO berries VALUES ('cherry');
> INSERT INTO berries VALUES ('bilberry');
> exit;
$ /etc/init.d/mysql restart
$ mysql -u root -p
> GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY '<some_password>'; 
> FLUSH PRIVILEGES;
> USE exampledb;
> INSERT INTO berries VALUES ('blackberry');
> FLUSH TABLES WITH READ LOCK;
> SHOW MASTER STATUS;

此时,显然我应该看到日志文件的一些详细信息,但我看到的是:

Empty set (0.00 sec)

有什么想法吗?即使再次重新启动后,/var/log/mysql.err/var/log/mysql.log 都是空的。

谢谢!

UPDATE: have edited to add actual data to the database, but still the same problem.

I'm working with a vanilla install of Debian (6.0.1), up-to-date versions of MySQL, and trying to set up MySQL database replication.

This is what I've done so far:

$ apt-get upgrade
$ apt-get install mysql-client mysql-server 
$ vi /etc/mysql/my.cnf
  # Comment out bind-addressb 
  # bind-address            = 127.0.0.1 
  # Add these lines
  log-bin = /var/log/mysql/mysql-bin.log
  binlog-do-db=exampledb
  server-id=1
$ /etc/init.d/mysql restart
$ mysql -u root -p
> CREATE DATABASE exampledb;
> USE exampledb;
> CREATE TABLE berries (name VARCHAR(100));
> INSERT INTO berries VALUES ('cherry');
> INSERT INTO berries VALUES ('bilberry');
> exit;
$ /etc/init.d/mysql restart
$ mysql -u root -p
> GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY '<some_password>'; 
> FLUSH PRIVILEGES;
> USE exampledb;
> INSERT INTO berries VALUES ('blackberry');
> FLUSH TABLES WITH READ LOCK;
> SHOW MASTER STATUS;

At this point, apparently I should see some details of the log file, but what I'm seeing instead is:

Empty set (0.00 sec)

Any ideas? /var/log/mysql.err and /var/log/mysql.log are both empty, even after another restart.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫负雪 2024-11-12 10:09:02

最后想通了。

线索在MySQL手册中,其中它说:

In a different session on the master, use the SHOW MASTER STATUS statement

我正在使用同一个会话:)

Figured it out in the end.

The clue is in the MySQL manual, where it says:

In a different session on the master, use the SHOW MASTER STATUS statement

I was using the same session :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文