mysql建表语句显示错误

mysql建表语句显示错误


CREATE table message(
 uid char(6) not null PRIMARY KEY auto_increment COMMIT '用户id',
 uname varchar COMMIT '用户姓名',
 sex char(2) check(ssex='男' or ssex='女') COMMIT '用户性别',
 bir datetime COMMIT '用户出生日期',
 hobby char(8) COMMIT '爱好',
 pw char(8) COMMIT '密码',
 tx BLOB COMMIT '头像',
 dz varchar COMMIT '地址',
 phone char(11) COMMIT '电话',
 qq char(11) COMMIT 'qq',
 myself_pj text COMMIT '自我评价',
)COMMIT '信息表'

显示错误如下图:

img

自动递增字段 uid ,不能是 char 啊,得是 int,字符串怎么递增?

  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/844730
  • 你也可以参考下这篇文章:【mysql时区问题】mysql插入数据时间显示错误
  • 同时,你还可以查看手册:MySQL 使用MySQL作为文件存储 X 插件选项和系统变量 中的内容
  • 除此之外, 这篇博客: mysql密码错误解决方法中的 进入MYSQL密码提示错误 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • C:\Users\Newland>mysql -u root -p
    Enter password: ******
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    

    解决方法:跳过密码来修改密码

    1. net stop mysql 中止mysql服务
    C:\Users\Newland>net stop mysql
    MySQL 服务正在停止.
    MySQL 服务已成功停止。
    
    1. 在mysql文件下创建my.ini,在里面写如以下内容
      在这里插入图片描述
      如果有my.ini就在[mysqld]下添加skip-grant-tables即可

    2. 回到cmd,用net start mysql 打开mysql服务

    C:\Users\Newland>net start mysql
    MySQL 服务正在启动 .             
    MySQL 服务已经启动成功。
    

    注意: 命令敲错了会启动失败,回去重新敲。

    1. 输入mysql -u root -p后直接回车进入
    C:\Users\Newland>mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.7.36 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2021, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql>
    
    1. use mysql使用mysql数据库
    mysql> use mysql
    Database changed
    
    1. select * from user where user=‘root’;查找用户为root的记录
    mysql> select * from user where user='root';
    +-----------+------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+-----------------------+-------------------+----------------+
    | Host      | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin                | authentication_string                     | password_expired | password_last_changed | password_lifetime | account_locked |
    +-----------+------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+-----------------------+-------------------+----------------+
    | localhost | root | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *9F84F1831BC1BB3DBFC9D1A0E555836070D0BA45 | Y                | 2022-04-20 09:43:03   |              NULL | N              |
    +-----------+------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+-----------------------+-------------------+----------------+
    1 row in set (0.00 sec)
    

    其中authentication_string字段是用来存放密码的

    1. 修改authentication_string字段内容

    update user set authentication_string=PASSWORD(“root123”) where user=‘root’;

    
    mysql> update user set authentication_string=PASSWORD("root123")where user='root';
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    1. 删除my.ini文件,关闭服务在开启即可
  • 您还可以看一下 李胜金老师的MySQL数据库从入门到精通实战教程课程中的 MySQL 显示数据库实例小节, 巩固相关知识点
  • 以下回答由chatgpt基于相关博客总结生成:

    很抱歉,参考资料中没有具体的问题描述,无法确定需要解决的问题是什么。请提供具体的问题描述和错误提示,以便能够给出准确的解决方案。如果是关于MySQL建表语句的问题,需要提供更详细的建表语句。