這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)如何解析MySQL的坑比時(shí)區(qū)問題,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
目前累計(jì)服務(wù)客戶千余家,積累了豐富的產(chǎn)品開發(fā)及服務(wù)經(jīng)驗(yàn)。以網(wǎng)站設(shè)計(jì)水平和技術(shù)實(shí)力,樹立企業(yè)形象,為客戶提供網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、網(wǎng)絡(luò)營銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。成都創(chuàng)新互聯(lián)始終以務(wù)實(shí)、誠信為根本,不斷創(chuàng)新和提高建站品質(zhì),通過對領(lǐng)先技術(shù)的掌握、對創(chuàng)意設(shè)計(jì)的研究、對客戶形象的視覺傳遞、對應(yīng)用系統(tǒng)的結(jié)合,為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。
mysql時(shí)區(qū)
mysql> show variables like '%zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
系統(tǒng)時(shí)區(qū)
[root@iZ2ze66bhrbxkc31nljgjnZ ~]# date -R
Fri, 23 Jun 2017 16:06:46 +0800
很好沒毛病
MariaDB [ecejmaster]> desc svc_street_tmp_170623;
+--------------+-------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+-------------------+-----------------------------+
| street_id | int(11) | NO | | 0 | |
| city_id | int(11) | YES | | NULL | |
| street_name | varchar(50) | NO | | | |
| status | tinyint(4) | YES | | NULL | |
| create_user | int(11) | YES | | NULL | |
| create_time | datetime | NO | | CURRENT_TIMESTAMP | |
| update_user | int(11) | YES | | NULL | |
| update_time | datetime | YES | | NULL | |
| del_flag | tinyint(4) | NO | | 0 | |
| screate_time | timestamp | NO | | CURRENT_TIMESTAMP | |
| supdate_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+--------------+-------------+------+-----+-------------------+-----------------------------+
MariaDB [ecejmaster]> select * from svc_street_tmp_170623 where street_id=17615 limit 1;
+-----------+---------+-------------+--------+-------------+---------------------+-------------+---------------------+----------+---------------------+---------------------+
| street_id | city_id | street_name | status | create_user | create_time | update_user | update_time | del_flag | screate_time | supdate_time |
+-----------+---------+-------------+--------+-------------+---------------------+-------------+---------------------+----------+---------------------+---------------------+
| 17615 | 69 | 123 | 2 | 1 | 2017-06-23 15:37:24 | 1 | 2017-06-23 15:37:24 | 0 | 2017-06-23 15:37:24 | 2017-06-23 15:38:36 |
+-----------+---------+-------------+--------+-------------+---------------------+-------------+---------------------+----------+---------------------+---------------------+
1 row in set (0.00 sec)
[dbaadmin@YZ-PRO-DB-04 ~]$ mysqldump -udbmanager -p'12fAK1aR' -h 10.32.14.78 ecejmaster svc_street_tmp_170623 --where="street_id=17615" -t
-- MySQL dump 10.15 Distrib 10.0.23-MariaDB, for Linux (x86_64)
--
-- Host: 10.32.14.78 Database: ecejmaster
-- ------------------------------------------------------
-- Server version 10.0.23-MariaDB-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00'*/;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `svc_street_tmp_170623`
--
-- WHERE: street_id=17615
LOCK TABLES `svc_street_tmp_170623` WRITE;
/*!40000 ALTER TABLE `svc_street_tmp_170623` DISABLE KEYS */;
INSERT INTO `svc_street_tmp_170623` VALUES (17615,69,'123',2,1,'2017-06-23 15:37:24',1,'2017-06-23 15:37:24',0,'2017-06-23 07:37:24','2017-06-23 07:38:36');
/*!40000 ALTER TABLE `svc_street_tmp_170623` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */
----看到?jīng)],時(shí)間少了8個(gè)小時(shí),仔細(xì)觀察會發(fā)現(xiàn)timestamp時(shí)間戳?xí)霈F(xiàn)少8個(gè)小時(shí)的狀況,datetime時(shí)間類型不會!插入到另外的庫中,時(shí)間會再加8個(gè)小時(shí),恢復(fù)正常
[dbaadmin@YZ-PRO-DB-04 ~]$ mysqldump --help | grep -i zone
--tz-utc SET TIME_ZONE='+00:00' at top of dump to allow dumping of
zones or data is being moved between servers with
different time zones.
默認(rèn)是以0時(shí)區(qū)來導(dǎo)出的,會對timestamp時(shí)間類型造成影響
mysqldump -uroot -S /data/3306/mysql.sock -pHP2T9wypjr6oEZRV ecejmaster3 $i --compact -c -t --skip-extended-insert --skip-tz-utc 跳過時(shí)區(qū)
mysqldump會對timestamp時(shí)間類型的字段造成8個(gè)小時(shí)的誤差,存insert時(shí)使用skip-tz-utc跳過時(shí)區(qū)的方式導(dǎo)出解決
上述就是小編為大家分享的如何解析mysql的坑比時(shí)區(qū)問題了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。