Loading

MySQL一些使用出错记录和解决

1.连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory

在mac 10.14中:
找到mysql.sock文件的位置
$sudo find / -name mysql.sock

------结果如下----------
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/private/tmp/mysql.sock

检查/var/mysql是否存在
$ll /var/mysql

如果/var/mysql不存在则创建
$sudo mkdir /var/mysql

将mysql.sock文件映射到/var/mysql路径中
$sudo ln -s /private/tmp/mysql.sock  /var/mysql/mysql.sock
重新刷新错误页面......

2.MySQL 5.7 修改root用户密码:

mysql -u root -p
> 输入密码进入管理
> set password for 'root'@'localhost'=password('123');
> flush privileges;
> quit;

3.mysql 5.7之后的版本常报错,"this is incompatible with sql_mode=only_full_group_by"错误解决方案:

# 查看当前sql_mode
select version(),@@sql_mode;
| 8.0.12    | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |

将上面内容,去除ONLY_FULL_GROUP_BY,到/etc/my.cnf下配置sql_mode,再重启mysqld

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
posted @ 2020-03-13 16:20  集君  阅读(77)  评论(0编辑  收藏  举报