2019年12月1日星期日

MySQL, SQLite 常见疑问解答

此处汇总了我在使用 MySQL,SQLite 过程中遇到并找寻答案的一些问题。

GUI 图形界面


MySQL强烈推荐HeidiSQL,免费。scoop 可安装。官方的 workbench 总感觉图形元素、字体太小,看着不舒服。

SQLite 的 GUI 不如mysql的强大好用,目前推荐 sqlitebrowser,开源免费。

创建table前,检查是否存在:create table if not exists


例如:
CREATE TABLE IF NOT EXISTS "event" (
    "id" INTEGER NOT NULL PRIMARY KEY,
    "key" TEXT NOT NULL,
    "timestamp" DATETIME NOT NULL,
    "metadata" TEXT NOT NULL);

Mysql INSERT、REPLACE、UPDATE的区别

参看:https://my.oschina.net/chinahub/blog/505119

注:sqlite 也支持 replace

python mysql helper

https://github.com/luvvien/python-mysql-helper
https://github.com/sweetycode/sqlexec
https://github.com/ItisDL/python-mysql-helper

https://github.com/Shypes/python-mysql-connector-wrapper

https://github.com/DropFan/mysql_helper

python mysql dump


https://github.com/Larryrun80/MysqlDumper

关闭 mysqld 服务


windows的mysql自带一个Notifier,可以启动,关闭mysqld服务。Linux中,直接使用service mysqld stop/start 关闭服务。 使用 ps aux |grep mysqld 查看mysql进程是否关闭。

mysql, sqlite: 关于 backtick(`,tab键上方的案件)


“mysql 的 backtick ` 符号”等同于“sqlite 的 "" 引号”。

https://stackoverflow.com/questions/10573922/what-does-the-sql-standard-say-about-usage-of-backtick

Difference Between Schema / Database in MySQL

简单来说,在 MySQL 里 schema = database。在其他一些 sql 里,schema 是 database 的子集,schema 表示某用户有权限的 database 的子集。

https://stackoverflow.com/questions/11618277/difference-between-schema-database-in-mysql

mysql中的utf8mb4、utf8mb4_unicode_ci、utf8mb4_general_ci

结论:用 utf8mb4_general_ci
https://www.cnblogs.com/amyzhu/p/9595665.html


mysql 两个数据库同步数据


https://dba.stackexchange.com/questions/65351/sync-two-mysql-databases-in-two-different-locations

IPv6 的 fe80开头的地址

fe80开头的 ipv6 地址不是公网地址,没人给你分ip,自动协商的地址,通常无法用于上网。 现在各大运营商用的ipv6: 电信是240e开头的(240e::/20) 移动是2409开头的(2409:8000::/20) 联通是2408开头的(2408:8000::/20)