Linux MySQL Permission denied on dynamic mounted drive - mysql

So I've installed MySQL on my PC (Linux Mint 21).
I mounted the dynamic NTFS Windows drive via ldmtool and tried to launch MySQL:
$ mysqld --datadir=/media/ffx/Data/MySQLDB
Got an 13 error (Permission denied).
Then:
# mysqld --user=root --datadir=/media/ffx/Data/MySQLDB
Same error...
Full log:
2022-12-01T15:43:28.814379Z 0 [Warning] [MY-010091] [Server] Can't create test file /media/ffx/Data/MySQLDB/mysqld_tmp_file_case_insensitive_test.lower-test
2022-12-01T15:43:28.814433Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) starting as process 6743
2022-12-01T15:43:28.816359Z 0 [Warning] [MY-010091] [Server] Can't create test file /media/ffx/Data/MySQLDB/mysqld_tmp_file_case_insensitive_test.lower-test
2022-12-01T15:43:28.816365Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /media/ffx/Data/MySQLDB/ is case insensitive
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2022-12-01T15:43:28.817066Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-12-01T15:43:28.817153Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-0ubuntu0.22.04.1) (Ubuntu).
I remounted the drive and set the 'ffx' owner (my account) instead of root
But this:
# mysqld --user=root --datadir=/media/ffx/Data/MySQLDB
$ mysqld --user=ffx --datadir=/media/ffx/Data/MySQLDB
$ mysqld --datadir=/media/ffx/Data/MySQLDB
Are also failed.
I remounted the disk to set the 'mysql' owner (so mysql:mysql is owner of WHOLE disk):
# mount /dev/mapper/... /media/ffx/Data -o uid=mysql -o gid=mysql
Now mysql user is owner of whole disk and it still gives that 13 error.
I've tried launch it from the root, ffx and mysql and got failed with the same error.
I also did this after every error:
# chown -R mysql:mysql /media/ffx/Data/MySQLDB
# chown -R mysql:mysql /media/ffx/Data/MySQLDB/
# chown -R mysql:mysql /media/ffx/Data/MySQLDB/*
but it also failed.
No result:
$ mysqld --install
$ mysqld --initialize
Creating an init file with
ALTER USER 'root'#'localhost' IDENTIFIED BY 'YourNewPassword';
Giving an 777 access to Data;
Giving an 777 access to MySQLDB
So question is what should I do and why doesn't it have permissions.

Related

docker ubuntu container install mysql-server always stuck in "Cannot stat file /proc/433/fd/0: Permission denied"

I find similar question but not answer fix my bug
how to reproduce
when init ubuntu:22.04 container without any modification
run docker exec test-ubuntu bash -c "apt update; apt install mysql-server"
mysql stuck in "Renaming removed key_buffer and myisam-recover options (if present)"
full output:
Renaming removed key_buffer and myisam-recover options (if present)
Cannot stat file /proc/433/fd/0: Permission denied
Cannot stat file /proc/433/fd/1: Permission denied
Cannot stat file /proc/433/fd/2: Permission denied
Cannot stat file /proc/433/fd/3: Permission denied
Cannot stat file /proc/433/fd/4: Permission denied
Cannot stat file /proc/433/fd/5: Permission denied
Cannot stat file /proc/433/fd/6: Permission denied
Cannot stat file /proc/433/fd/7: Permission denied
Cannot stat file /proc/433/fd/8: Permission denied
Cannot stat file /proc/433/fd/9: Permission denied
Cannot stat file /proc/433/fd/10: Permission denied
Cannot stat file /proc/433/fd/11: Permission denied
Cannot stat file /proc/433/fd/12: Permission denied
Cannot stat file /proc/433/fd/13: Permission denied
Cannot stat file /proc/433/fd/14: Permission denied
Cannot stat file /proc/433/fd/15: Permission denied
Cannot stat file /proc/433/fd/16: Permission denied
Cannot stat file /proc/433/fd/17: Permission denied
Cannot stat file /proc/433/fd/18: Permission denied
Cannot stat file /proc/433/fd/19: Permission denied
Cannot stat file /proc/433/fd/20: Permission denied
Cannot stat file /proc/433/fd/21: Permission denied
Cannot stat file /proc/433/fd/22: Permission denied
Cannot stat file /proc/433/fd/23: Permission denied
Cannot stat file /proc/433/fd/24: Permission denied
Cannot stat file /proc/433/fd/25: Permission denied
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 1030
Error: Unable to shut down server with process id 1030
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Setting up libhttp-date-perl (6.05-1) ...
Setting up libclone-perl (0.45-1build3) ...
Setting up libhtml-tagset-perl (3.20-4) ...
Setting up liblwp-mediatypes-perl (6.04-1) ...
Setting up libencode-locale-perl (1.05-1.1) ...
Setting up libhtml-parser-perl:amd64 (3.76-1build2) ...
Setting up libhttp-message-perl (6.36-1) ...
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Setting up libcgi-pm-perl (4.54-1) ...
Setting up libhtml-template-perl (2.97-1.1) ...
Setting up libcgi-fast-perl (1:2.15-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
when i run docker exec test-ubuntu bash -c 'cat /var/log/mysql/error.log', cannot find any error
2023-02-16T03:25:14.092640Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.22.04.2) initializing of server in progress as process 980
2023-02-16T03:25:14.099155Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-16T03:25:15.437369Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-16T03:25:19.676899Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2023-02-16T03:25:23.597131Z 6 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.32-0ubuntu0.22.04.2).
2023-02-16T03:25:29.456978Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0ubuntu0.22.04.2) starting as process 1028
2023-02-16T03:25:29.470270Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-02-16T03:25:29.724484Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-02-16T03:25:30.124681Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-02-16T03:25:30.124748Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-02-16T03:25:30.129841Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2023-02-16T03:25:30.147250Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2023-02-16T03:25:30.147299Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32-0ubuntu0.22.04.2' socket: '/tmp/tmp.c4bayLhPNX/mysqld.sock' port: 0 (Ubuntu).
2023-02-16T03:25:30.175862Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.32-0ubuntu0.22.04.2).
2023-02-16T03:25:31.861822Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32-0ubuntu0.22.04.2) (Ubuntu).
I find if use ubuntu 18.04 and use mysql 5.7, apt install mysql-server work in docker, but when install mysql-server >= 8.0, it raise this error
so if I wanna install mysql-server >= 8.0, I have following way:
way1:
when create docker container, use --privileged=true, but it effect host's security
way2:
I think the better solution is don't use privileged=true(has security risk), instead, build mysql from source and install it

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.

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

MySQL abort right after starting

Like described in the title, mysql stop just after starting, i searched in a lot of topics and every solutions proposed doesn't work for me...
i'm on up to date os x with a fresh install of mysql 8.0 via DMG.
my my_pc.err file in the mysql/data folder indicate this:
2020-05-20T14:43:07.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2020-05-20T14:43:07.693358Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20) starting as process 25586
2020-05-20T14:43:07.697083Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2020-05-20T14:43:07.697155Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2020-05-20T14:43:07.697233Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-20T14:43:07.697410Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
2020-05-20T14:43:07.6NZ mysqld_safe mysqld from pid file /usr/local/mysql/data/MacBook-Pro-de-CanardWc.local.pid ended
2020-05-20T14:43:17.6NZ mysqld_safe Logging to '/usr/local/mysql/data/MacBook-Pro-de-CanardWc.local.err'.
2020-05-20T14:43:17.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
It's been now few years that i try to use mysql and never manage to make it working. I tried :
sudo /usr/local/mysql/support-files/mysql.server start, it gave me this :
Starting MySQL . ERROR! The server quit without updating PID file (/usr/local/mysql/data/MacBook-Pro-de-CanardWc.local.pid).
i used chmod on my mysql folder.
i changed my path on bash_profile but mysql and mysqld commands is still not found.
i also tried this:
/usr/local/mysql/bin/mysqladmin --port=8889 -u root shutdown
it responds this:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)'
Check that mysqld is running and that the socket: '/var/mysql/mysql.sock' exists!
ps -ef | grep mysqld gave me this information :
501 22093 549 0 6:52PM ttys004 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mysqld
/usr/local/mysql/bin/mysql -h 127.0.0.1 -P 3306 -u root -p
give this:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
my /var/mysql/mysql.sock is empty
sudo pkill mysqld
doesn't kill the process
did a fresh reinstal using https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks but when i do mysql_secure_installation i got this error:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
After few search, i found out that that i just needed to uninstall it and reinstall it with brew. Pretty sad that the dmg doesn't work but now i can use mysql properly.
Thanks a lot for the time you took to help me <3

Keyring mirgration failure Fedora mySql

I've been working through MySQL but I've been having trouble entering my MySQL server to change certain properties. When I attempt to enter as root I get the following output:
//]$ sudo mysqld -u root -p
Enter password:
mysqld: Can not perform keyring migration : Invalid --keyring-migration-source option.
2020-02-12T05:34:59.837715Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 64421
2020-02-12T05:34:59.839462Z 0 [ERROR] [MY-011084] [Server] Keyring migration failed.
2020-02-12T05:34:59.839481Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-02-12T05:34:59.839559Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
Can't figure out how to sort this out. Any help would be much appreciated.
keyring-migration-source exists in one of the configuration files.
mysqld --help --verbose will list which files are read at the top. Look in those and remove the line.
Also don't run mysqld as root. Its a security hazard and won't start. Use the systemctl start mysql that fedora provides.