Heim  >  Artikel  >  Datenbank  >  MySQL 初学者可能会遇到的问题_MySQL

MySQL 初学者可能会遇到的问题_MySQL

WBOY
WBOYOriginal
2016-06-01 13:06:541258Durchsuche



MySQL 向含有自增长列的表中插入记录注意:

      Insert into 表名 values (值); 省略了列则需要随意填写一个符合增长列类型的数据即可,否则报不匹配错。

      Inert into 表名 (列名) values (值); 此种写法可以不写增长列;

MySQL 错误:there can be only one auto column and it must be defined as a key

今天在创建一个表的时候,结果报出了这个错误,there can be only one auto column and it must be defined as a key,后来Google搜索从一个英国的网站上找到了答案,原因是你有一个字段(以下用A字段表示)设置了auto_increment,另一个字段(以下用B字段表示)有设置为主键,这是错误的,因为MySQL将自动增长的字段看作逐渐,因此按照这样的逻辑,你的表里就有两个主键,所以方法是将B字段的逐渐索引去掉,如果你的意思是想让B字段的数据不重复,那么你可以使用Unique来限制。 

MySQL 远程连接:

如果使用 grant all on *.* to root@% identified by password 命令还是无法让远程连接到,则可以 使用sudo vi /etc/mysql/my.cnf 用vi打开文件,并找到bind-address=127.0.0.1,按插入insert键,用#注释掉这行,Esc键,再打:wq 回车 ,OK!,重启mysql既可以远程连接了。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn