MySQL报错汇总

2024-08-16 09:35:38 浏览数 (1)

Ignoring query to other database

 【报错原因】

  登陆数据库缺少参数

代码语言:javascript复制
[root@localhost ~]# mysql -root -p

【解决方法】

  补全的参数,整句话意思是使用root用户去登陆密码为000000

代码语言:javascript复制
[root@localhost ~]# mysql -uroot -p000000

【错误示例】

代码语言:javascript复制
[root@localhost ~]# mysql -root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 21
Server version: 5.5.48-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

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> show databases;
Ignoring query to other database
mysql> Ctrl-C -- exit!
Aborted

【解决示例】

代码语言:javascript复制
[root@localhost ~]# mysql -uroot -p000000
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 23
Server version: 5.5.48-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

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> show databases;
 -------------------- 
| Database |
 -------------------- 
| information_schema |
| mysql |
| performance_schema |
| test |
 -------------------- 
4 rows in set (0.00 sec)

ERROR:No query specified

【报错原因】

  sql语句后加“;”

代码语言:javascript复制
mysql> select * from user G;

【解决方法】

  sql语句后不加“;”

代码语言:javascript复制
mysql> select * from user G

【错误示例】

【解决示例】

ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number

【报错原因】

  语句中的password是不需要的

【解决方法】

  去掉password

【错误示例】

代码语言:javascript复制
mysql>  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '000000' WITH GRANT OPTION ;
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number

【解决示例】

代码语言:javascript复制
mysql>  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY  '000000' WITH GRANT OPTION ;
Query OK, 0 rows affected (0.00 sec)

2003 - can't connect to MySQL server on 'xxxxx'(10060 "Unknown error")

ssh可以正常登陆,ssh访问通过mysql命令可以进入数据库,使用Navicat连接报错

【报错原因】

  防火墙问题,使用的是oneinstack一键安装工具这个会自己给你安装iptables

【解决方法】

代码语言:javascript复制
service iptables stop

Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'

【报错原因】

  主键没有设置自动增长

【解决方法】

将主键设为自动增长

General error: 1030 Got error 28 from storage engine

【报错原因】

  服务器磁盘满啦

【解决方法】

删除不必要的日志文件或者增加磁盘

1241 - Operand should contain 1 column(s)

【报错原因】

这个语句的出现多是因为将select 的结果集用()包住了。

代码语言:javascript复制
WHERE UNIX_TIMESTAMP(w.create_time ) between (1569254400,1569859199)

【解决方法】

代码语言:javascript复制
WHERE UNIX_TIMESTAMP(w.create_time ) between 1569254400 AND 1569859199

1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'a.msg_type' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

【报错原因】

mysql版本的问题,5.7.27版本

【解决办法】

代码语言:javascript复制
MySQL [mysql]> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)

MySQL [mysql]> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)

Data too long for column 'matter' at row 1

【报错原因】

1数据库表里面的字段长度过少(我是这个原因)

【解决办法】

设置为255,解决了

mysqldump: [Warning] Using a password on the command line interface can be insecure.

【报错原因】

mysql5.7版本,安全机制做了改变,直接写不行了

【解决办法】

代码语言:javascript复制
vi  /etc/my.cnf

[client]
port = 3306
socket = /tmp/mysql.sock
host = 127.0.0.1
user = root
password = password

重新载入配置文件

代码语言:javascript复制
service mysqld reload

运行命令

代码语言:javascript复制
/usr/local/mysql/bin/mysqldump --defaults-extra-file=/etc/my.cnf  -R -E -e --all-databases  | gzip > $backupdir/database_$date_str.sql.gz 

General error: 1030 Got error 28 from storage engine

【报错原因】

服务器磁盘满了

【解决办法】

1. 扩容磁盘

2. 清除日志文件

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

【报错原因】

PHP查询绑定参数的问题

【解决办法】

代码语言:javascript复制
//问号占位符
Db::query("select * from think_user where id=? AND status=?", [8, 1]);
// 命名绑定
Db::execute("update think_user set name=:name where status=:status", ['name' => 'thinkphp', 'status' => 1]);

0 人点赞