search
HomeDatabaseMysql Tutorial在linux下写的mysql无法插入,sql语句在复制中变'脏'了.

1:问题故障描述 因为在linux下开发,所以修改mysql字段的时,用的phpmyadmin来直接修改生成修改后的sql,然后复制进word(libreoffice)后提交到项目管理系统, 同事发到项目管理系统后不能运行.于是有了这篇文章. 2:首先新建表 CREATE TABLE IF NOT EXISTS `nns_a

1:问题故障描述

因为在linux下开发,所以修改mysql字段的时,用的phpmyadmin来直接修改生成修改后的sql,然后复制进word(libreoffice)后提交到项目管理系统,

同事发到项目管理系统后不能运行.于是有了这篇文章.


2:首先新建表

CREATE TABLE IF NOT EXISTS `nns_ad_log_count` (
  `nns_id` char(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '广告ID',
  `nns_access_type` tinyint(4) NOT NULL COMMENT '0:5m 1:1h 2:24h=1d',
  `nns_access_day` date NOT NULL COMMENT '哪一天的',
  `nns_access_index` int(11) NOT NULL COMMENT '间隔数,5m 1h 1d=24h',
  `nns_access_count` int(11) NOT NULL
) ENGINE=InnoDb DEFAULT CHARSET=utf8;

这步是OK的.

接着因为项目扩展,增加了1个字段,同时需要修改一个表的字段名和另外几个表的default 默认值和类型

ALTER TABLE `nns_ad_log_count` CHANGE `nns_id` `nns_ad_id` CHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '广告ID';

上面这步,是用的phpmyadmin添加的字段后生成的一句sql, 看上去是没问题的,复制到word里面,再拿到mysql里面执行一下

在linux下写的mysql无法插入,sql语句在复制中变'脏'了.

在linux下写的mysql无法插入,sql语句在复制中变'脏'了.

报错了.百思不得其解,

为什么会这样子呢?


3: 错误分析.

生成的sql,是干净的, 途中同事只粘贴进了word. 

于是手写了一遍这个sql,并且在mysql里面运行 (为了测试,我复制了上面的表结构,并且新建了一个测试的表`nns_ad_log_count1`)

在linux下写的mysql无法插入,sql语句在复制中变'脏'了.

运行正常

同事只复制了一次,粘贴到了word (libreoffice) 

我重复一下他的动作

"1. 先用浏览器打开phpmyadmin,在phpmyadmin里面直接修改一次,产生sql语句"

"2. 在phpmyadmin 里面,复制生成的sql到系统的剪贴板缓存"

"3. 粘贴进word"

"4. 重复其他的修改操作,重复1,2,3步"

"5. 把整个word发送给我"

"6. 我把word里面的sql拷贝出来,运行 "

"7. 报错"

打开word,发现sql的语句的空格在word里面高亮了

在linux下写的mysql无法插入,sql语句在复制中变'脏'了.

但是在mysql里面直接执行并没能看见这个东西,在phpmyadmin里面执行上面的sql

在linux下写的mysql无法插入,sql语句在复制中变'脏'了.

空格显示出来了,原来是这个

自此问题已经明了.sql语句在复制到word后给污染了. 但是为什么会这样子污染呢? 发现只有word粘贴进去后,会把utf8下的空格换成

这个应该是linux下的office工具的问题, 这里就不再陈述了


4: 后记, 在linux下做开发提交的sql语句,

建议复制到vim里面查看详细的格式,

或者更简单的,复制出来后,在浏览器地址栏粘贴一次再复制进word来提交文档.以免sql变脏出错.




Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor