msqld: Can't change dir (OS errno 13 - Permission denied) - mysql

I installed mysql for Mac 10.14 using the .dmg file at the top here: https://dev.mysql.com/downloads/mysql/, and ran through the installer. My system os is Mac 10.13.6, but there is a note that says this should work.
At /usr/local/ there's both a mysql folder and a mysql-8.0.13-macos10.14-x86_64 folder.
When I run mysqld I get the following error:
mysqld: Can't change dir to '/usr/local/mysql-8.0.13-macos10.14-x86_64/data/' (OS errno 13 - Permission denied)
ts 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0.13-macos10.14-x86_64/bin/mysqld (mysqld 8.0.13) starting as process 9863
ts 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql-8.0.13-macos10.14-x86_64/data/Monicas-MacBook-Pro.lower-test
ts 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql-8.0.13-macos10.14-x86_64/data/ is case insensitive
ts 0 [ERROR] [MY-010172] [Server] failed to set datadir to /usr/local/mysql-8.0.13-macos10.14-x86_64/data/
ts 0 [ERROR] [MY-010119] [Server] Aborting
ts 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0.13-macos10.14-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.13) MySQL Community Server - GPL.
ts is the UTC timestamp.
Is the problem that the command mysqld comes from /usr/local/mysql/ and the directory to write to /usr/local/mysql-8.0.13...../data/? Does my user on my work computer not have the correct permissions to write to these directories?
I've tried sudo:
Please read "Security" section of the manual to find out how to run mysqld as root!

Restart computer.
If that doesn't work:
If you are in a virtualenv try installing required python-to-mysql libraries globally, that also helped.
The final thing to try is
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/:${DYLD_LIBRARY_PATH}"

Related

MYSQL 8 in WSL Ubuntu 20.04 change directory

I managed to change the Mysql directory normally as shown in some tutorials, however it does not start, I changed the mysql 8 data's directory that is in /var/lib/mysql to /mnt/d/mysql, either with a copy of the databases that were running or the location zeroed, it does not start. The error log gives the following message:
[System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-0ubuntu0.20.04.2) (Ubuntu). mysqld_safe mysqld from pid file /mnt/d/mysql/VERIFIQIMOVEIS.pid ended mysqld_safe Logging to '/var/log/mysql/error.log'. mysqld_safe Starting mysqld daemon with databases from /mnt/d/mysql [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161) [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000) [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.20.04.2) starting as process 21204 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /mnt/d/mysql/ is case insensitive [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7e204e29-9132-11ed-aeb5-32ceaa8792ed. [ERROR] [MY-011011] [Server] Failed to find valid data directory. [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. [ERROR] [MY-010119] [Server] Aborting
I tried to set permissions with
sudo chown -R mysql:mysql /mnt/d/mysql sudo chmod -R 755 /mnt/d/mysql
I went to /etc/apparmor.d/tunables/alias and put the new path on the line
alias /var/lib/mysql/ -> /mnt/d/mysql/,
Well, after many attempts trying to make MySQL 8 work, changing its directory (appdir) to another HD (D:) using the path mnt/d/, I uninstalled mysql and installed MariaDB, which in my case came to work, I had just create a user 'debian-sys-maint'#'localhost' and set the same password that appears in /etc/mysql/debian.cnf this experience of mine is recorded, I hope one day it will help someone.

mysql installation with datadir home directory of user giving permission denied error 13

I am trying to initialize the mysql and datadir=/home/user/mysqldata
but it is througing the error permission denied
root#localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/user/mysql-data
2021-11-23T17:35:24.562009Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2021-11-23T17:35:24.562124Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.27-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.27) initializing of server in progress as process 56149
2021-11-23T17:35:24.564873Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/home/user/mysql-data/' (OS errno: 13 - Permission denied)
2021-11-23T17:35:24.564881Z 0 [ERROR] [MY-013236] [Server] The designated data directory /home/user/mysql-data/ is unusable. You can remove all files that the server added to it.
2021-11-23T17:35:24.564978Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-11-23T17:35:24.565137Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0.27-linux-glibc2.12-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.27) MySQL Community Server - GPL.```
I create a folder /home/user/mysql-data and changed the ownership to mysql and changed the mode also to 750/777 also.
Also disabled selinux, Os is centos 6.9

Cannot connect to the MySQL database server, there are error messages but I do not know what the problem is and how to solve it

I get the below error messages and think that I have more than one problem:
The first one is common:
mysql-bin.index' not found (Errcode: 13)
and I want to solve it by
chgrp -R mysql /usr/local/mysql/data && chown -R mysql /usr/local/mysql/data
But I got another error message:
chown: /usr/local/mysql/data/.DS_Store: Operation not permitted
I do not know how to solve these...
2020-09-12T04:15:42.843047Z 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0.21-macos10.15-x86_64/bin/mysqld (mysqld 8.0.21) starting as process 1012
2020-09-12T04:15:42.849049Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql-8.0.21-macos10.15-x86_64/data/ is case insensitive
2020-09-12T04:15:42.855324Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-09-12T04:15:42.855495Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0.21-macos10.15-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL.
These are other error messages. Can anyone figure out the problem and the solution for me?
File '/etc/mysql/var/​log-bin.index' not found (Errcode: 13). Doesn't mean it's not there; Error 13 means "Permission denied" Which If there is no .index file, and no binlogs mysql will just start over from scratch Remove any files in that directory.
Option 1:
service mysqld stop
Copy the log files including the .index file to new location.
cp mysql-bin.log* /path/to/binlogs
cp mysql-bin.index /path/to/binlogs
Do Changes in the /etc/my.cnf file.
[mysqld]
log-bin=/path/to/newdirecory/mysql-bin
log-bin-index=/path/to/newdirectory/mysql-bin.index
service mysqld start
Option 2:
Use this utiltiy to relocate binary logs:
mysqlbinlogmove --binlog-dir=/server/data /new/binlog_dir

File './binlog.000007' not found (OS errno 2 - No such file or directory)

I have this error when running mysql
mysqld: File './binlog.000007' not found (OS errno 2 - No such file or directory)
2019-06-10T01:08:57.188811Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 2210
2019-06-10T01:08:57.871257Z 0 [ERROR] [MY-010958] [Server] Could not open log file.
2019-06-10T01:08:57.871297Z 0 [ERROR] [MY-010041] [Server] Can't init tc log
2019-06-10T01:08:57.873856Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-06-10T01:08:59.423691Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.16) MySQL Community Server - GPL.
Does anyone know how to fix it?
In the same directory, you'll find binlog.index file.
windows: C:\Program Files\MySQL\MySQL Server X.0\data\binlog.index
Linux: /var/lib/mysql/binlog.index
Remove entry of './binlog.000007' and restart the server..
You don't say where you're running MySQL (inside Virtual Box, or a Docker image; Windows or Linux), but this should resolve the problem:
https://dba.stackexchange.com/questions/151183/mariadb-cant-init-tc-log
Woohoo, I found it! For now, at least. Digging through the source
suggests that this might have something to do with mmap() calls, and
lo and behold - VirtualBox has a bug in that area. Fortunately that
same source hints at a workaround - the log_bin option. Enable this
(either from the command line as --log_bin or from the config file
as log_bin=ON) and things start to work again!

MySQL: mysqld in cmd returns "Can't change dir to..."

I've just joined to ask for help regarding this.
Whenever I type mysqld in CMD I get the following:
mysqld: Can't change dir to 'c:\Program Files\MySQL\MySQL Server 8.0\data\' (OS
errno 2 - No such file or directory)
2018-08-12T09:16:41.903311Z 0 [System] [MY-010116] [Server] c:\Program Files\MyS
QL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.12) starting as process 2740
2018-08-12T09:16:41.965711Z 0 [Warning] [MY-010091] [Server] Can't create test f
ile c:\Program Files\MySQL\MySQL Server 8.0\data\Moonwilles-PC.lower-test
2018-08-12T09:16:41.965711Z 0 [Warning] [MY-010091] [Server] Can't create test f
ile c:\Program Files\MySQL\MySQL Server 8.0\data\Moonwilles-PC.lower-test
2018-08-12T09:16:41.965711Z 0 [ERROR] [MY-010172] [Server] failed to set datadir
to c:\Program Files\MySQL\MySQL Server 8.0\data\
2018-08-12T09:16:41.965711Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-08-12T09:16:41.965711Z 0 [System] [MY-010910] [Server] c:\Program Files\MyS
QL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Com
munity Server - GPL.
I've looked literally everywhere, I installed MySQL using the MySQL installer on 3 different computers, I got the same problem on all of them. This is the most ridiculous and frustrating thing I've ever encountered.
The MySQL service is on.
I tried typing mysqld --initialize and it seems to have made things worse as whenever I type 'mysqld' CMD now 'freezes' momentarily before actually executing the command.
The 'my.ini' file is setup correctly.
The data directory is in 'C:\ProgramData\MySQL\MySQL Server 8.0\Data'.
I've forgotten my root password and I am trying to recover it. I followed the guide found here: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html and it's not even working.
I cannot log in to phpMyAdmin anymore.