您的位置:首页 > 数据库 > MySQL

mysql数据库相关笔记

2020-02-03 04:31 731 查看

1、数据及sql语句
****(1)插入数据出错:
mysql 5.7.9 [Err] 1055 插入时候会报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
解决办法:
在sql命令行执行 SET sql_mode=(SELECT REPLACE(@@sql_mode,‘ONLY_FULL_GROUP_BY’,’’));
(2)用navicat连接数据库报错:
1130-host … is not allowed to connect to this MySql server
原因:
这个问题是因为在数据库服务器中的mysql数据库中的user的表中没有权限(也可以说没有用户)。
解决办法:
1、连接服务器: mysql -u root -p 2、进入mysql数据库:use mysql; 3、修改user表中的Host:update user set Host=’%’ where User=‘root’; 4、最后刷新一下:flush privileges;
(3)数据库模糊查询和插入问题:
查询:%替换成\%,_替换成\ _,\替换成 \\\\
插入:\替换为\\

例如:
/java中sql模糊查询特殊字符(,%和_)处理/
/从前台jsp获取的查询条件/
String username = request.getParameter(“username”);
if(username != null && !"".equals(username))
{
//注意顺序,一定要先替换,再替换_和%(_和%不分顺序)
String name=username.replace("\\", “\\\\\\\\”).replace("_", “\\_”).replace("%","\\%");
}
(4)客户端navicat通过mysql命令查看mysql的安装路径:
select @@basedir as basePath from dual

  • 点赞
  • 收藏
  • 分享
  • 文章举报
淺晓 发布了10 篇原创文章 · 获赞 1 · 访问量 253 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: