MySQL_异常

时间:2022-03-06 00:57:54

问题1


  描述:在连接MYSQL数据库时出现问题:“ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)”

  分析:从错误的提示中可以看出MySQL服务没有启动,因此只需要启动MySQL服务就可以了。

  解决:直接采用net start mysql就可以启动MySQL服务

  扩展:启动:输入 net start mysql

     停止:输入 net stop mysql

问题2


  描述:连接本地数据库出现问题:“1045 access denied for user 'root'@'localhost' using password yes”

  分析:这时可以考虑换个密码看看了

  解决:1.找到my.ini或者my.cnf

     2.在[mysqld]下加"skip_grant_tables"

     3.重启MySQL(service mysql restart或者net stop mysql&&net start mysql)

     4.mysql登录

     5.use mysql;

     6.update user set password=password("123") where user="root";

     7.flush privileges;

     8.exit;

     9.将"skip_grant_tables"去掉

     10.重启MySQL,使用设置好的密码和root用登陆即可

问题3


  描述:子查询时出现问题:“1248 - Every derived table must have its own alias”

      原语句:

 SELECT
applicant_name
FROM
(
SELECT
b.id AS bid,
c.POSTSTATUS,
l.id AS lid,
c.SYNCSTATUS,
l.APPLICANT_NAME APPLICANT_NAME,
b.BUSINESS_LICENSE,
l.LICENCE,
b.LEGAL_NAME,
l.YWLB,
l.LICENCE_BEGINTIME
FROM
applicant_licence_info l
LEFT JOIN applicant_base_INFO b ON l.APPLICANT_ID = b.ID
LEFT JOIN oa_licence_courier c ON c.LICENCE_ID = l.ID
WHERE
1 = 1
ORDER BY
LICENCE_BEGINTIME DESC
)
WHERE
APPLICANT_NAME = '苏州新科兰德科技有限公司'

  分析:子查询的结果必须要有一个别名

  解决:

 SELECT
applicant_name
FROM
(
SELECT
b.id AS bid,
c.POSTSTATUS,
l.id AS lid,
c.SYNCSTATUS,
l.APPLICANT_NAME APPLICANT_NAME,
b.BUSINESS_LICENSE,
l.LICENCE,
b.LEGAL_NAME,
l.YWLB,
l.LICENCE_BEGINTIME
FROM
applicant_licence_info l
LEFT JOIN applicant_base_INFO b ON l.APPLICANT_ID = b.ID
LEFT JOIN oa_licence_courier c ON c.LICENCE_ID = l.ID
WHERE
1 = 1
ORDER BY
LICENCE_BEGINTIME DESC
) AS a
WHERE
a.APPLICANT_NAME = '苏州新科兰德科技有限公司'