分类 默认分类 下的文章

执行 yum 或者 dnf的时候报错

Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

Fix Failed to download metadata for repo
CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. It means that CentOS 8 will no longer receive development resources from the official CentOS project. After Dec 31st, 2021, if you need to update your CentOS, you need to change the mirrors to vault.centos.org where they will be archived permanently. Alternatively, you may want to upgrade to CentOS Stream.
执行了以下两条命令替换了yum.repos.d配置文件的内容后,成功修复了问题

cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum update -y

linux 经常运行某个软件的时候,报错提示某个库文件没有,但也不清楚这个库文件是要安装哪个软件
报错 libgtk-x11-2.0.so.0 这个文件没有,怎么办

./chrome: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

用这个命令一查就知道了,需要安装 gtk2-2.24.31-1.el7 软件

repoquery --nvr --whatprovides libgtk-x11-2.0.so.0
gtk2-2.24.31-1.el7

repoquery 这个命令需要安装 yum-utils 工具就会有了^-^

yum install yum-utils

现在愉快的玩耍吧

ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employees.employees.emp_no' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

三种方式来解决。

一、关闭 ONLY_FULL_GROUP_BY
可以选择关掉 MySQL 的 ONLY_FULL_GROUP_BY 模式。

有两种方式,通过昨晚设置 sql_mode 来关闭。

首先查看变更前的 sql_mode:

第二种是找到 MySQL 配置文件修改并保存。

MySQL 的配置文件名为 my.cnf,可通过以下命令查看你位置:

$ mysql --help | grep cnf
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

找到后编辑并保存,重启 MySQL 后生效。

ANY_VALUE()
还可以通过 ANY_VALUE() 来改造查询语句以避免报错。

使用 ANY_VALUE() 包裹的值不会被检查,跳过该错误。所以这样是可以的:

SELECT gender, 
-       last_name
+       ANY_VALUE(last_name) 
FROM   employees 
GROUP  BY gender 

添加列间的依赖
像这个示例中,

SELECT gender, 
       last_name 
FROM   employees 
GROUP  BY gender 

假如我们让 gender 变成不重复的主键,last_name 便与 gender 产生了一种关系,即 gender 可唯一确定 last_name。此时便可进行 GROUP BY 了。因为,之所以报错是因为在进行聚合的时候有不能确定的列参与了进来。

YII 1.1 要启用禁用 csrf
要在controlled的 beforeAction 方法中 设置 enableCsrfValidation 的值 ,如下:

public function beforeAction($action) {
 Yii::app()->request->enableCsrfValidation = true;
return parent::beforeAction($action);
}