MySQL Binary Logs (binlog) Management
The MySQL binary log contains “events” that describe database changes such as table creation operations or changes to table data. It is the oplog of mysql, and we can subscribe the log to follow all the actions.
Tag
6 posts
MySQL Community Server is the world's most popular open source database.
The MySQL binary log contains “events” that describe database changes such as table creation operations or changes to table data. It is the oplog of mysql, and we can subscribe the log to follow all the actions.
It is a common operation to create a user and giant all the permission to a specific database.
对 string 稍作处理, 避免在写 query 的时候被 SQL 注入, 这是常识. 我们若变更 PHP 版本, 有时候会出现 Call To Undefined Function 这样的错误. 很多时候, 我们需要做出一些兼容性的处理.
不过, 若我们是在 WordPress 的平台上写插件, 则不必这么麻烦了.
在实际操作中,我们常常有一些各种古怪的需求,比如现在这个。数据库的table中有一个自增的id字段,插入数据库后,要求返回刚刚插入那条数据的id。 在单线程情况下,这当然是一个很简单的问题。首先获得数据库的最大id,给将要插入的语句id赋值为MAX+1,然后插入即可。 Oracle也很容易实现,给这个table建立一个sequence,每次都向这个sequence获取下一个id,效率也是价格公道童叟无欺。 但是,给多线程下的mysql返回刚刚插入的id,这似乎有点小为难。一个立刻可以想到的方法是,给插入操作加个锁,插入后查询MAX id,然后解开锁。但是这个显然是不怎么讲究了。
linux下存储数据,mysql无疑是个很不错的选择。mysql的默认存储路径为/var/lib/mysql。以前数据库一直不是很大,总共十个G左右的大小,放在默认路径毫无压力。但是今天,因为新导入一个数据库,光是导入数据就是30+G,瞬间就悲剧了,因为我并没有为/目录准备足够的硬盘分区空间。所以,修改配置,迁移数据库存储路径到合适的地方成了最省力的选择。
OS 为 Windows 7 X64,IDE 为Code::Blocks, 编译器为 mingw64, 使用 mysql,得到错误提示道:
"SOCKET" does not name a type