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 '信息表'
显示错误如下图:
自动递增字段 uid ,不能是 char 啊,得是 int,字符串怎么递增?
C:\Users\Newland>mysql -u root -p
Enter password: ******
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解决方法:跳过密码来修改密码
C:\Users\Newland>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
在mysql文件下创建my.ini,在里面写如以下内容
如果有my.ini就在[mysqld]下添加skip-grant-tables即可
回到cmd,用net start mysql 打开mysql服务
C:\Users\Newland>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
注意: 命令敲错了会启动失败,回去重新敲。
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>
mysql> use mysql
Database changed
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字段是用来存放密码的
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
很抱歉,参考资料中没有具体的问题描述,无法确定需要解决的问题是什么。请提供具体的问题描述和错误提示,以便能够给出准确的解决方案。如果是关于MySQL建表语句的问题,需要提供更详细的建表语句。