简体   繁体   English

对于MySQL中的用户表,建议使用哪种字段类型和存储引擎?

[英]What field types and storage engine are recommended for a user table in MySQL?

I have my PhpMyAdmin SQL table for users 我有供用户使用的PhpMyAdmin SQL表

Name [id, username, password, email, website, status(1,2), role(1,2)]
Type [INT, VARCHAR, VARCHAR, VARCHAR, TEXT, VARCHAR, VARCHAR]
INDEX [PRIMARY, INDEX, INDEX, INDEX, INDEX, INDEX, INDEX]

How do i fix this? 我该如何解决? And what Storage Engine do you recommend me to use? 您建议我使用什么存储引擎? And is there a better way for databases that would exceed the limited size? 对于超出限制大小的数据库,是否有更好的方法? maybe something not Maria Db? 也许不是Maria Db? or this is the best for PHP? 还是这是最适合PHP的?

You should consider: 您应该考虑:

  • Username must be UNIQUE, otherwise it could be created duplicated user names. 用户名必须为UNIQUE,否则可以创建重复的用户名。
  • You may consider email as unique (unless a user can create multiple accounts with the same email). 您可能会认为电子邮件是唯一的(除非用户可以使用同一电子邮件创建多个帐户)。
  • website could be a varchar(255 or less) field if you dont need a large text for a website url. 如果您不需要用于网站网址的大文本,则网站可以是varchar(255或更少)字段。 Also creating a index over a text column is only a good practice if you want full text search. 如果要全文搜索,则在文本列上创建索引也是一个好习惯。 Also you need to specify a index prefix length to avoid a large index file. 另外,您还需要指定索引前缀长度,以避免大的索引文件。

You can take a look at https://dev.mysql.com/doc/refman/5.6/en/column-indexes.html for more directions about indexes. 您可以查看https://dev.mysql.com/doc/refman/5.6/en/column-indexes.html,以获取有关索引的更多说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM