MySQL常见报错汇总
1>.ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
报错原因:
在MySQL的配置⽂件中未指定“--secure-file-priv”参数的默认值,⽽改参数的功能就是确定使⽤SELECT ... INTO语句时将查询的结果保存到本地⽂件中,如果未指定则不可以使⽤该功能。
解决⽅案:
既然知道原因所在,我们需要做2个操作,第⼀步是修改配置⽂件,如下所⽰。第⼆步就是重启MySQL服务使得配置⽣效~
[root@node110 ~]# cat /etc/myf | grep secure_file_priv
secure_file_priv=/yinzhengjie/backup
[root@node110 ~]#
[root@node110 ~]# /etc/init.d/mysql.server restart
Shutting SUCCESS!
Starting MySQL. SUCCESS!
[root@node110 ~]#
2>.ERROR 1 (HY000): Can't create/write to file '/yinzhengjie/backup/student.bak' (OS errno 13 - Permission denied)
报错原因:
根据报错的提⽰信息⼤家不难判断,这是由于权限不⾜导致!
解决⽅案:
既然知道的报错的原因,解决起来就很轻松了,⽐如改⽬录分配相应的权限,⼀种⽐较暴⼒的⽅法就是给该⽬录分配最⾼权限。如下所⽰:(当然你也可以只给启动mysql服务的⽤户分配ACL权限~)
[root@node110 backup]# pwd
/yinzhengjie/backup
mysql下载starting the server[root@node110 backup]#
[root@node110 yinzhengjie]# ll
total 12
drwxr-xr-x. 2 root root 4096 Jan 2615:08backup
drwxr-xr-x. 2 root root 4096 Jan 2306:04 download
drwxr-xr-x. 3 root root 4096 Jan 2306:04 softwares
[root@node110 yinzhengjie]# chmod 777backup-R
[root@node110 yinzhengjie]#
[root@node110 yinzhengjie]#
[root@node110 yinzhengjie]# ll
total 12
drwxrwxrwx. 2 root root 4096 Jan 2615:08backup
drwxr-xr-x. 2 root root 4096 Jan 2306:04 download
drwxr-xr-x. 3 root root 4096 Jan 2306:04 softwares
[root@node110 yinzhengjie]#
3>.ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
报错原因:
根据上⾯的提⽰,想必⼤家猜的已经⼋九不离⼗来,这是我们开启了bin-log, 我们就必须指定我们的函数是否是上述提⽰信息中的“DETERMINISTIC (不确定的)”,“ NO SQL (没有SQl语句,当然也不会修改数据)”,“ READS SQL DATA (只是读取数据,当然也不会修改数据)”,“MODIFIES SQL DATA 要修改数据” ,“CONTAINS SQL (包含了SQL语句)”。
其中在function⾥⾯,只有 DETERMINISTIC, NO SQL 和 READS SQL DATA 被⽀持。如果我们开启了 bin-log, 我们就必须为我们的function指定⼀个参数。
解决⽅案:
在MySQL中创建函数时出现上述错误的解决⽅法,如下:
mysql> SHOW VARIABLES LIKE'log_bin'; #在MySQL8.0中,log_bin被打开了,在MySQL5.7之前的版本是关闭状态的!
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin |ON|
+---------------+-------+
1 row in set (0.00 sec)
mysql>
mysql> SHOW VARIABLES LIKE'%trust%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators |OFF|
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql>
mysql>set global log_bin_trust_function_creators=TRUE; #由于开启了log_bin功能,因此我们需要将创建函数的功能⼿动开启
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> SHOW VARIABLES LIKE'%trust%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators |ON|
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql>set global log_bin_trust_function_creators=TRUE;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>CREATE FUNCTION hello(str CHAR(30))
->RETURNS CHAR(50)
->RETURN CONCAT('Hello,',str,'!');
Query OK, 0 rows affected (0.00 sec)
mysql>
4>.mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
报错原因:
缺少依赖库⽂件,名⽈“libaio.so”。
解决⽅案:
既然知道缺少依赖库⽂件,我们直接使⽤yum⼯具安装⼀下即可!具体操作如下所⽰:
[root@node101 ~]# yum -y install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud
* extras: usoft.edu
* updates: mirrors.163
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================= Package Arch Version Repository Size
================================================================================================================================================================================= Installing:
libaio x86_64 0.3.109-13.el7 base 24 k
Transaction Summary
================================================================================================================================================================================= Install 1 Package
Total download size: 24 k
Installed size: 38 k
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libaio-0.3.109-13.el7.x86_64 1/1
Verifying : libaio-0.3.109-13.el7.x86_64 1/1
Installed:
libaio.x86_64 0:0.3.109-13.el7
Complete!
[root@node101 ~]#
[root@node101 ~]# yum -y install libaio
5>.mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
报错原因:
很明显是⽂件权限问题,⼤家可以⾃⾏去看"/etc/myf"配置⽂件的内容配置的是否正确,如果你配置的⽬录或⽂件不存在的话,可能会抛出各种各
样的异常!
解决⽅案:
[root@node101 ~]# mkdir /var/log/mariadb
[root@node101 ~]#
[root@node101 ~]# touch /var/log/mariadb/mariadb.log
[root@node101 ~]#
[root@node101 ~]# chown -R mysql:mysql /var/log/mariadb/
[root@node101 ~]#
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论