我最近将我的mysql迁移到另一台服务器, 迁移后,有些奇怪。
当我使用mysql作为远程主机时:
$ mysql -u root -p -h remote
mysql> select id from People order by id desc limit 10;
+-----+
| id |
+-----+
| 941 |
| 940 |
| 939 |
| 938 |
| 937 |
| 936 |
| 935 |
| 934 |
| 933 |
| 932 |
+-----+
但是当我从localhost使用时:
$ mysql -u root -p
mysql> select id from People order by id desc limit 10;
+-----+
| id |
+-----+
| 939 |
| 938 |
| 937 |
| 936 |
| 935 |
| 934 |
| 933 |
| 932 |
| 931 |
| 930 |
+-----+
查询结果缺少2行!
我还检查了PRIVILEGES:
对于远程案例,它显示
mysql> show grants;
+--------------------------------------------------------------------------------------------------------------------------+
| Grants for root@example.com |
+--------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'example.com' IDENTIFIED BY PASSWORD '521f3dd02c6d22f8' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
对于localhost,它具有相同的权限,
mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
有人可以帮我解释为什么user @ host?
之间的查询结果不同答案 0 :(得分:0)
我猜你没有提交你的交易。使用InnoDB表并激活隐式事务设置时,首先必须在第一个客户端中投射commit
,以使所有用户都可以看到您的更改。
答案 1 :(得分:0)
确定, 我终于找到了原因。
看来这张桌子因某种原因而崩溃,需要修理 我转到mysql数据目录并通过以下命令修复:
$ myisamchk -r People
- recovering (with sort) MyISAM-table 'People'
Data records: 703
- Fixing index 1
Data records: 705
从输出中可以看到丢失的2条记录又回来了~~