在Linux下写的MySQL无法插入,sql语句在复制中变'脏'了
1:问题故障描述 因为在linux下开发,所以修改mysql字段的时,用的phpmyadmin来直接修改生成修改后的sql,然后复制进word(libreoffice)后提交到项目管理系统, 同事发到项目管理系统后不能运行.于是有了这篇文章. 2:首先新建表 1.CREATE TABLE IF NOT EXISTS `nns_
1:问题故障描述因为在linux下开发,所以修改mysql字段的时,用的phpmyadmin来直接修改生成修改后的sql,然后复制进word(libreoffice)后提交到项目管理系统,
同事发到项目管理系统后不能运行.于是有了这篇文章.
2:首先新建表
1.CREATE TABLE IF NOT EXISTS `nns_ad_log_count` (
2. `nns_id` char(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '广告ID', 3. `nns_access_type` tinyint(4) NOT NULL COMMENT '0:5m 1:1h 2:24h=1d', 4. `nns_access_day` date NOT NULL COMMENT '哪一天的', 5. `nns_access_index` int(11) NOT NULL COMMENT '间隔数,5m 1h 1d=24h', 6. `nns_access_count` int(11) NOT NULL 7.) ENGINE=InnoDb DEFAULT CHARSET=utf8;
这步是OK的.
接着因为项目扩展,增加了1个字段,同时需要修改一个表的字段名和另外几个表的default 默认值和类型
1.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里面执行一下
报错了.百思不得其解,
为什么会这样子呢?
3: 错误分析.
生成的sql,是干净的, 途中同事只粘贴进了word.
于是手写了一遍这个sql,并且在mysql里面运行 (为了测试,我复制了上面的表结构,并且新建了一个测试的表`nns_ad_log_count1`)
运行正常
同事只复制了一次,粘贴到了word (libreoffice)
我重复一下他的动作
"1. 先用浏览器打开phpmyadmin,在phpmyadmin里面直接修改一次,产生sql语句"
"2. 在phpmyadmin 里面,复制生成的sql到系统的剪贴板缓存"
"3. 粘贴进word"
"4. 重复其他的修改操作,重复1,2,3步"
"5. 把整个word发送给我"
"6. 我把word里面的sql拷贝出来,运行 "
"7. 报错"
打开word,发现sql的语句的空格在word里面高亮了
但是在mysql里面直接执行并没能看见这个东西,在phpmyadmin里面执行上面的sql
空格显示出来了,原来是这个Â
自此问题已经明了.sql语句在复制到word后给污染了. 但是为什么会这样子污染呢? 发现只有word粘贴进去后,会把utf8下的空格换成Â
这个应该是linux下的office工具的问题, 这里就不再陈述了
4: 后记, 在linux下做开发提交的sql语句,
建议复制到vim里面查看详细的格式,
或者更简单的,复制出来后,在浏览器地址栏粘贴一次再复制进word来提交文档.以免sql变脏出错

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

To uninstall an Oracle database: stop the Oracle service, remove the Oracle instance, delete the Oracle home directory, clear the registry key (Windows only), and delete the environment variables (Windows only). Please back up the data before uninstalling.

Using Docker on Linux can improve development and deployment efficiency. 1. Install Docker: Use scripts to install Docker on Ubuntu. 2. Verify the installation: Run sudodockerrunhello-world. 3. Basic usage: Create an Nginx container dockerrun-namemy-nginx-p8080:80-dnginx. 4. Advanced usage: Create a custom image, build and run using Dockerfile. 5. Optimization and Best Practices: Follow best practices for writing Dockerfiles using multi-stage builds and DockerCompose.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

After Oracle is installed, you can use the following steps: Create a database instance. Connect to the database. Create a user. Create a table. Insert data. Query data. Export data. Import data.
