mysqld: Can't create/write to file (Errcode: 13) - mysql

I installed mariadb on my archlinux box recently and wanted to run mysqld with different data and tmp directories
[mysqld]
user = mysql
port = 3306
datadir = <datapath>
tmpdir = <datapath>/tmp
When running mysqld I get the following error messages:
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.8
InnoDB: Using Linux native AIO
[ERROR] mysqld: Can't create/write to file '<datapath>/tmp/ib8dOkCX' (Errcode: 13)
InnoDB: Error: unable to create temporary file; errno: 13
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] mysqld: Can't create/write to file '<datapath>/aria_log_control' (Errcode: 13)
[ERROR] mysqld: Got error 'Can't create file' when trying to use aria control file '<datapath>/aria_log_control'
[ERROR] Plugin 'Aria' init function returned error.
[ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
[Note] mysqld: Shutdown complete
I have made sure that the mysql user is the owner and has the proper permissions on the data and tmp directories.
When running mysqld as root, everything works just fine. When using the default tmpdir I still get the error when create/write to file /aria_log_control. Anyone who knows where I fail?

you should replace <datapath> with real path to data files which contains folder tmp

Related

can't access local mariadb mac: InnoDB error

I am trying to setup MariaDB on my local machine.
Whenever I try to log in with:
mariadb -u <mac_name> or mariadb -u root I get this error:
using my mac password also doesn't work.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When I tail the logs found at /usr/local/var/mysql/<host_name>.err or /usr/local/var/mysql/<host_name>.local.err
I get these errors:
[Note] InnoDB: Completed initialization of buffer pool
[ERROR] InnoDB: Invalid flags 0x4800 in ./ibdata1
[ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
[Note] InnoDB: Starting shutdown...
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[Note] Plugin 'FEEDBACK' is disabled.
[ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
Does anyone know how I could get this working?

MySQL 5.7 change datadir

I use MySQL 5.7 and CentOS 7.2.
At first, my datadir configuration in my.cnf is /var/lib/mysql
Now I want to change datadir.
I hava try two ways:
First, I copy all files and directories in /var/lib/mysql to /home/data, and run chown -R mysql:mysql /home/data. But when I run systemctl start mysqld, I get error message:
2016-12-08T16:33:38.206780Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2016-12-08T16:33:38.206806Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2016-12-08T16:33:38.206817Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2016-12-08T16:33:38.807398Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-12-08T16:33:38.807421Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-12-08T16:33:38.807429Z 0 [ERROR] Failed to initialize plugins.
2016-12-08T16:33:38.807436Z 0 [ERROR] Aborting
Second, I move /var/lib/mysql to /home and run ln -s /home/mysql mysql in /var/lib directory. When I run systemctl start mysqld, I get error message:
2016-12-08T16:48:28.958136Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2016-12-08T16:48:28.958165Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2016-12-08T16:48:28.958174Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
2016-12-08T16:48:28.958184Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2016-12-08T16:48:29.558751Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-12-08T16:48:29.558792Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-12-08T16:48:29.558806Z 0 [ERROR] Failed to initialize plugins.
2016-12-08T16:48:29.558817Z 0 [ERROR] Aborting
How can I deal with it?
this problem is about subdir permission
and you should edit this file /etc/apparmor.d/local/usr.sbin.mysqld
/data/ r,
/data/** rwk,
do not forgot, and you should find same command at centos, like this
sudo service apparmor reload
about this problem at ubuntu sys, and see link
https://askubuntu.com/questions/758898/mysql-wont-start-after-changing-the-datadir-14-04-mysql-5-7/795710#795710
happy day, baddy

mysql: can't change tmpdir to anything except /tmp

I create /mysqltmp directory as a root user and give it the same permissions as the /tmp directory (chmod 1777 /mysqltmp). But when I start mysql, service fails to start and I get the following error in logs:
/usr/sbin/mysqld: Can't create/write to file '/mysqltmp/ib9AeHFf' (Errcode: 13)
140417 9:46:46 InnoDB: Error: unable to create temporary file; errno: 13
140417 9:46:46 [ERROR] Plugin 'InnoDB' init function returned error.
140417 9:46:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140417 9:46:46 [ERROR] Unknown/unsupported storage engine: InnoDB
140417 9:46:46 [ERROR] Aborting
Error 13 is "Permission denied".
MySQL server version is 5.5.35 and OS is Ubuntu 12.04.4.

Can't add a MySQL cartridge on OpenShift

I went to spin up a new application today and I'm running into some issues. I was able to add the PHP 5.4 cartridge just fine. I went to add a MySQL 5.5 cartridge and I received the following:
Starting MySQL 5.5 cartridge
MySQL server failed to start:
140320 03:05:46 mysqld_safe Logging to '/var/lib/openshift/532a883a4382ec501600043b/mysql//log/mysql_error.log'.
140320 03:05:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/openshift/532a883a4382ec501600043b/mysql/data/
140320 03:05:51 mysqld_safe mysqld from pid file /var/lib/openshift/532a883a4382ec501600043b/mysql/pid/mysql.pid ended
140320 03:05:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/openshift/532a883a4382ec501600043b/mysql/data/
140320 3:05:48 [Note] Plugin 'FEDERATED' is disabled.
140320 3:05:48 InnoDB: The InnoDB memory heap is disabled
140320 3:05:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140320 3:05:48 InnoDB: Compressed tables use zlib 1.2.3
140320 3:05:48 InnoDB: Using Linux native AIO
140320 3:05:48 InnoDB: Warning: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
InnoDB: Warning: io_setup() attempt 1 failed.
InnoDB: Warning: io_setup() attempt 2 failed.
InnoDB: Warning: io_setup() attempt 3 failed.
InnoDB: Warning: io_setup() attempt 4 failed.
InnoDB: Warning: io_setup() attempt 5 failed.
140320 3:05:51 InnoDB: Error: io_setup() failed with EAGAIN after 5 attempts.
InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
140320 3:05:51 InnoDB: Fatal error: cannot initialize AIO sub-system
140320 3:05:51 [ERROR] Plugin 'InnoDB' init function returned error.
140320 3:05:51 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140320 3:05:51 [ERROR] Unknown/unsupported storage engine: InnoDB
140320 3:05:51 [ERROR] Aborting
140320 3:05:51 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: Shutdown complete
140320 03:05:51 mysqld_safe mysqld from pid file /var/lib/openshif /532a883a4382ec501600043b/mysql/pid/mysql.pid ended
Failed to execute: 'control start' for /var/lib/openshift/532a883a4382ec501600043b/mysql
I've seen one other question that seems similar, but was when attempting to restart their app.
Any idea how to fix this problem?
Looks like there is a bug (http://elenst.ru/mariadb/aio-max-nr-in-general-and-innodb-error-io_setup-failed-with-eagain-in-particular/) (http://bugs.mysql.com/bug.php?id=61575) we are looking into work arounds

Mysql did not start

I tried to restart mysql. However it did not restart. Here is the content of mysql.log:
131217 17:01:09 InnoDB: Starting shutdown...
131217 17:01:11 InnoDB: Shutdown completed; log sequence number 153229469
131217 17:01:11 [Note] /usr/libexec/mysqld: Shutdown complete
131217 17:01:11 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
131217 17:01:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
131217 17:01:11 [Note] Plugin 'FEDERATED' is disabled.
131217 17:01:11 InnoDB: The InnoDB memory heap is disabled
131217 17:01:11 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131217 17:01:11 InnoDB: Compressed tables use zlib 1.2.3
131217 17:01:11 InnoDB: Using Linux native AIO
^G/usr/libexec/mysqld: Can't create/write to file '/tmp/ibsMvrkL' (Errcode: 13)
131217 17:01:11 InnoDB: Error: unable to create temporary file; errno: 13
131217 17:01:11 [ERROR] Plugin 'InnoDB' init function returned error.
131217 17:01:11 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
131217 17:01:11 [ERROR] Unknown/unsupported storage engine: InnoDB
131217 17:01:11 [ERROR] Aborting
Can any one help me to find the reason of this? In fact mysql was working before this time and it seems that it is not a regular error!!Please let me know if any other information is nedeed.
Thanks a lot
Have you checked if there is a problem about your disk partition. May be its out of space or have a problem. The error clearly shows the problem is caused by creating temp file failure. Rest is listed because InnoDB failed to initialize.
This error clearly mentioned that MySQL daemon unable to create a temporary file under /tmp directory.
Please check the permission of /tmp directory.
Your /tmp directory permission should have a sticky bit. below is the example for same.
drwxrwxrwt 3 root root 4.0K Feb 4 13:48 tmp