I can not start the MySQL Server from command line in windows - mysql

Whenever I write the command "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld" the command prompt hits back with something like this:
C:\>"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld"
141110 3:12:58 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.5\data\Dutta.lower-test
141110 3:12:58 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.5\data\Dutta.lower-test
141110 3:12:58 [Note] Plugin 'FEDERATED' is disabled.
141110 3:12:58 InnoDB: The InnoDB memory heap is disabled
141110 3:12:58 InnoDB: Mutexes and rw_locks use Windows interlocked functions
141110 3:12:58 InnoDB: Compressed tables use zlib 1.2.3
141110 3:12:58 InnoDB: Initializing buffer pool, size = 128.0M
141110 3:12:58 InnoDB: Completed initialization of buffer pool
141110 3:12:58 InnoDB: Operating system error number 5 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory. It may also be you have created a subdirectory
InnoDB: of the same name as a data file.
InnoDB: File name .\ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
I'm just a beginner. May be a silly mistake. Sorry in advance !!

I think I got it. I had the exact same problem and actually ended up uninstalling and reinstalling a couple of times; until...
start> CMD> c:\Program Files\MySQL Server 5.7\bin> mysql -u root -p
Hope its as simple for u too. I kinda laughed when I noticed.

The context and privileges of the current user will take affect when you manually start the executable in this way.
You either need to make sure:
The current user has the correct permissions to all files and directories required
You elevate permissions of the command prompt to run as an administrator
If you have the MySQL service installed you can also use net start MySQL.
This page of the MySQL manual contains useful information for installing and running the MySQL server on windows.
Please remember that once you have 'started' the MySQL service (or service) you won't actually see anything, you will then need to use a MySQL client application to connect to the server and interact.

I'm posting this answer in case it solves it for some people.
All I had to do was to:
Open task manager
Open Services tab
Find MySQL80 service and start it.
then just start the MySQL workbench and refresh the schemas.

Related

InnoDB: Attempted to open a previously opened tablespace

I have been working on a problem for a few days now. Our local mediawiki page that sits on our box account, destroyed itself and we've been working to get it online. Using XAMPP Control Panel v3.2.1, the errors were numerous so we decided to update XAMPP (v3.2.2) and move the 'htdocs' and 'mysql/data' files over to the new data base.
First error:
9:50:21 AM [mysql] Attempting to start MySQL app...
9:50:22 AM [mysql] Status change detected: running
9:50:22 AM [mysql] Status change detected: stopped
9:50:22 AM [mysql] Error: MySQL shutdown unexpectedly.
9:50:22 AM [mysql] This may be due to a blocked port, missing dependencies,
9:50:22 AM [mysql] improper privileges, a crash, or a shutdown by another method.
9:50:22 AM [mysql] Press the Logs button to view error logs and check
9:50:22 AM [mysql] the Windows Event Viewer for more clues
9:50:22 AM [mysql] If you need more help, copy and post this
9:50:22 AM [mysql] entire log window on the forums
As it says, I then went to the logs and found this:
2015-11-20 09:50:22 11f8 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2015-11-20 9:50:22 4600 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2015-11-20 9:50:22 4600 [Note] InnoDB: The InnoDB memory heap is disabled
2015-11-20 9:50:22 4600 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2015-11-20 9:50:22 4600 [Note] InnoDB: Memory barrier is not used
2015-11-20 9:50:22 4600 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-11-20 9:50:22 4600 [Note] InnoDB: Not using CPU crc32 instructions
2015-11-20 9:50:22 4600 [Note] InnoDB: Initializing buffer pool, size = 16.0M
2015-11-20 9:50:22 4600 [Note] InnoDB: Completed initialization of buffer pool
2015-11-20 9:50:22 4600 [Note] InnoDB: Highest supported file format is Barracuda.
2015-11-20 9:50:22 4600 [Note] InnoDB: The log sequence numbers 1665234 and 1665234 in ibdata files do not match the log sequence number 50125498 in the ib_logfiles!
2015-11-20 9:50:22 4600 [Note] InnoDB: Database was not shutdown normally!
2015-11-20 9:50:22 4600 [Note] InnoDB: Starting crash recovery.
2015-11-20 9:50:22 4600 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-11-20 9:50:22 4600 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace phpmyadmin/pma__tracking uses space ID: 21 at filepath: .\phpmyadmin\pma__tracking.ibd. Cannot open tablespace wiki/archive which uses space ID: 21 at filepath: .\wiki\archive.ibd
InnoDB: Error: could not open single-table tablespace file .\wiki\archive.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
Now this looks like a standard error that I've seen with many different suggestions throughout the web on how to fix it. I will go over them briefly.
The first thing I tried was to follow the suggestions in the log.
The were no permission problems
It is not clear if I need the table or not, OR whether to get rid of phpmyadmin/pma__tracking or archive.ibd. When I got rid of the archive.ibd, the error just past on to another .ibd file.
'innodb_force_recovery=1' was added to my.cnf and this cause a bunch of errors.
The next thing I noticed is that when we built the new database, I got this error in my phpMyAdmin (localhost/phpMyAdmin):
phpMyAdmin error
I'm not sure if this is causing all of my problems or not. I found that people were saying to switch a password to =''. This error might be happening because I'm entering old data folders in a new database. I'm not sure.
The first suggestion on the web was to remove the following files from
\mysql\data:
innodb_index_stats.frm
innodb_index_stats.ibd
innodb_table_stats.frm
innodb_table_stats.ibd
slave_master_info.ibd
slave_relay_log_info.frm
slave_relay_log_info.ibd
slave_worker_info.frm
slave_worker_info.ibd
The 2nd:
I've tried removing 'ibdata1'
None of these have worked.
I had the same problem. I tried all the solution others has proposed, and unfortunately nothing worked.
After spending hours on searching for the solution in Google I finally found this
Open my.ini (my.cnf on linux-based systems and Mac)
Look for [mysqld]
Just below [mysqld] insert innodb_force_recovery = 1
Start MySQL Service
Stop MySQL Service
Remove the line from my.ini (innodb_force_recovery = 1)
Start MySQL Service
Worked perfect in my case.
I hope this will solve your problem.
I got the same error. These are the steps I followed.
Took the backup of \xampp\mysql\data
Removed all the files and folders from data folder except mysql
Quit and started the XAMPP again.
Move the databases from data folder one by one.
try to rename /Applications/XAMPP/xamppfiles/var/mysql/ib_logfile0 to /Applications/XAMPP/xamppfiles/var/mysql/ib_logfile0.bkp
and /Applications/XAMPP/xamppfiles/var/mysql/ib_logfile1 to /Applications/XAMPP/xamppfiles/var/mysql/ib_logfile1.bkp
Solution is for MAC 10.11.3 El Captian
Go to /Applications/XAMPP/xamppfiles/var/mysql/
Delete all random files (except the actual database folders)
Restart Apache and MySQL.
This worked for me.
To use the above (Nesar solution) in MAMP (version >= 4), you must first copy the my.cnf file that is inside MAMP/tmp/mysql to the MAMP/conf folder. Only then will it work.
I had a similar problem with Mamp Pro. For me it turned out the correct .idb-files were not located at "Applications/Mamp...". So taking a closer look at the error-log it showed me the files were located at "/Library/Application Support/appsolute/MAMP PRO/db". As I had problems with a database I wasn't using anymore, I just tried to delete the corresponding folder and it worked out. The next step would have been to delete the files already mentioned by the author.
innodb_index_stats.frm
innodb_index_stats.ibd
innodb_table_stats.frm
innodb_table_stats.ibd
slave_master_info.ibd
slave_relay_log_info.frm
slave_relay_log_info.ibd
slave_worker_info.frm
slave_worker_info.ibd
But as mentioned deleting the databasefolder worked out great.
Tgr's answer looks appropriate. The message about permissions etc. is a generic one; the actual error message is
2015-11-20 9:50:22 4600 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace phpmyadmin/pma__tracking uses space ID: 21 at filepath: .\phpmyadmin\pma__tracking.ibd. Cannot open tablespace wiki/archive which uses space ID: 21 at filepath: .\wiki\archive.ibd
Your wiki database and phpmyadmin database somehow ended up with the same tablespace ID. Each would work fine if the other wasn't present; as it is now, you'll have to renumber one of them somehow.
"Attempted to open a previously opened tablespace." -- That smells like one of these:
There are two copies of MySQL and both are trying to run.
Windows failed to release an 'open' on one of MySQL's files. I used to see that problem. It was cured by rebooting Windows; later by upgrading Windows.
Another solution for the issue discribed above for MAMP Pro, as I found impossible to edit my.cnf properly :
When InnoDB is crashing, spot in the error message the DB that is causing trouble. Here it is phpmyadmin/pma__tracking so the table is the one with the pma_ extension.
Then go to /Library/Application Support/appsolute/MAMP PRO/db/mysql and remove the folder named after the problem causing DB.
Restart your MAMP server.
Once you restarted with success, you can stop servers again, put back the DB folder where it belongs and start the servers again. Everything should be fine again.
I had the same problem, after use recovery database structure ( http://zadpen.com/20-restore-lost-data-in-mysql-using-innodb-engine-without-file-ibdata1.html )
I remove the archive.ibm file and start mysql.
then create archive table in database.
if someone has problems with any of their corrupt tables, this may be a possible solution to their problem, in my case I had the backup of my database so just delete the tables that are the files .ibd then restart MAMP PRO and mysql started correctly. A database backup must be taken into account. hope this helps someone and doesn't waste a lot of time. regards
after 4 hours i got solution without loos any data, please use below to resolve your issue
I had the same problem. I tried all the solution others has proposed, and unfortunately nothing worked.
After spending hours on searching for the solution in Google I finally found this
Open my.ini (my.cnf on linux centos /etc/my.cnf.d/server.cnf)
Look for [mysqld]
Just below [mysqld] insert innodb_force_recovery = 1
Start MySQL Service
Stop MySQL Service
Remove the line from my.ini (innodb_force_recovery = 1)
Start MySQL Service
Worked perfect in my case.
I hope this will solve your problem.

No connection could be made because the target machine actively refused it (PHP / WAMP)

Note: I realise this could be seen as a duplicate but i have looked at the other responses and they didn't fix the problem for me.
I have recently installed Zend Studio and Zend Server with the mysql plugin on Windows 7.
I am not a qualified server administrator but neither am i completely incompetent; i have dedicated my day trying to get a local development 'server' up to cut down on upload/download times.
When I say server/machine i mean my home computer
I have come to a grinding halt trying to get mysql to work with Zend Server.
The error I keep receiving is (or verbose):
#2002 Cannot log in to the MySQL server
or (if i change to 'config' authentication type)
#2002 - No connection could be made because the target machine actively refused it.
The server is not responding (or the local server's socket is not correctly configured).
I have tried:
Change $cfg['Servers'][$i]['host'] from 'localhost' to '127.0.0.1'
Add/Remove $cfg['Servers'][$i]['socket'] = '';
Change from cookie to config auth type
reinstall server and mysql
Disable firewalls
Restarting machine
Zend's approach was to 'configure the phpmyadmin setup screen'... done that i don't know how many times.
Can anyone on here lend a hand, or point me in a direction that I haven't tried yet?
Go to C:\wamp\bin\mysql\mysql[your-version]\data
Copy and save "ib_logfile0" and "ib_logfile1" anywhere else.
delete "ib_logfile0" and ib_logfile1
Did the trick for me. hope it works for you too.
Its working fine.
But we will have to stop apache and mysql, We need to quit xampp and then delete file. when deleted successfully. now start xampp it will work properly..
Just Go to your Control-panel and start Apache & MySQL Services.
You might need:
In wamp\bin\mysql\mysqlX.X.XX\my.ini find these lines:
[client]
...
port = 3308
...
[wampmysqld64]
...
port = 3308
As you see, the port number is 3308 (or maybe 3306). You should :
use that port in applications, like WordPress: define('DB_HOST', 'localhost:3308')
or
change it globally in wamp\bin\apache\apache2.X.XXX\bin\php.ini change
mysqli.default_port = ... to 3308
Till yesterday I was able to connect to phpMyAdmin, but today I started getting this error:
2002-no-connection-could-be-made-because-the-target-machine-actively-refused
None of the answers here really helped me fix the problem, what helped me is shared below:
I looked at the mysql logs.[C:\wamp\logs\mysql.log]
It said
2015-09-18 01:16:30 5920 [Note] Plugin 'FEDERATED' is disabled.
2015-09-18 01:16:30 5920 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-09-18 01:16:30 5920 [Note] InnoDB: The InnoDB memory heap is disabled
2015-09-18 01:16:30 5920 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2015-09-18 01:16:30 5920 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-09-18 01:16:30 5920 [Note] InnoDB: Not using CPU crc32 instructions
2015-09-18 01:16:30 5920 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-09-18 01:16:30 5920 [Note] InnoDB: Completed initialization of buffer pool
2015-09-18 01:16:30 5920 [Note] InnoDB: Highest supported file format is Barracuda.
2015-09-18 01:16:30 5920 [Note] InnoDB: The log sequence numbers 1765410 and 1765410 in ibdata files do not match the log sequence number 2058233 in the ib_logfiles!
2015-09-18 01:16:30 5920 [Note] InnoDB: Database was not shutdown normally!
2015-09-18 01:16:30 5920 [Note] InnoDB: Starting crash recovery.
2015-09-18 01:16:30 5920 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-09-18 01:16:30 5920 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace harley/login_confirm uses space ID: 6 at filepath: .\harley\login_confirm.ibd. Cannot open tablespace testdb/testtable which uses space ID: 6 at filepath: .\testdb\testtable.ibd
InnoDB: Error: could not open single-table tablespace file .\testdb\testtable.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
I got the clue that this guy is creating a problem - InnoDB: Error: could not open single-table tablespace file .\testdb\testtable.ibd
and this line 2015-09-18 01:16:30 5920 [Note] InnoDB: Database was not shutdown normally!
hmmm, For me the testdb was just a test-db! hence I decided to delete this file inside C:\wamp\bin\mysql\mysql5.6.17\data\testdb
and restarted all services, and went to phpMyAdmin, and this time no issues, phpMyAdmin opened :)
I'm having the same problem with Wampserver. It’s worked for me:
You must change this file: "C:\wamp\bin\mysql[mysql_version]\my.ini"
For example: "C:\wamp\bin\mysql[mysql5.6.12]\my.ini"
And change default port 3306 to 80. (Lines 20 & 27, in both)
port = 3306
To
port = 80
I hope this is helpful.
All I have to do in order to get rid of that error was to restart my wamp server.
In my case i did the following and worked for me
I clicked on the wamp icon.
i went to MySQL > Service administration 'wampmysqld64' > install service
Then click on wamp icon > Restart all service.
Please check your hosts file in etc folder and add below comments then run wamp server.
127.0.0.1 localhost
Path : C:\Windows\System32\drivers\etc
I have just removed the mysql service and installed it again. It works for me
Kindly check is your mysql-service is running.
for windows user: check the services - mysql service
for Linux user: Check the mysql service/demon is running (services mysql status)
Thanks & Regards
Jaiswar Vipin Kumar R
following steps worked for me.
Go to wamp\apps\phpmyadmin
search config.inc.php
search 127.0.0.1 and replace with "localhost".

InnoDB errors MySQL windows 8

I just upgraded from Windows 7 to Windows 8, however a lot of settings or files have changed and I can no longer connect to a MySQL database.
Here is the error I get:
130124 23:56:02 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.5\data\Randy-PC.lower-test
130124 23:56:02 [Warning] Can't create test file C:\Program Files\MySQL\MySQL Server 5.5\data\Randy-PC.lower-test
130124 23:56:02 [Note] Plugin 'FEDERATED' is disabled.
130124 23:56:03 InnoDB: The InnoDB memory heap is disabled
130124 23:56:03 InnoDB: Mutexes and rw_locks use Windows interlocked functions
130124 23:56:03 InnoDB: Compressed tables use zlib 1.2.3
130124 23:56:03 InnoDB: Initializing buffer pool, size = 128.0M
130124 23:56:03 InnoDB: Completed initialization of buffer pool
130124 23:56:03 InnoDB: Operating system error number 5 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory. It may also be you have created a subdirectory
InnoDB: of the same name as a data file.
InnoDB: File name .\ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
What can I do to get my database up and running again?
All help is greatly appreciated!
The most likely explanation is that the permissions on the MySQL data directory were modified by the Windows 8 upgrade.
From the error message, it looks like your InnoDB data directory may be C:\Program Files\MySQL\MySQL Server 5.5\data
Use Windows Explorer to navigate to that directory, right click, and open the Properties, and click on the Security tab. The service account that the MySQL services is running under needs to have Full access (all privileges) to that directory. When you click on Edit, there's two columns of check boxes for Allow and Deny... Full Control, Modify, Read & execute, etc.)
(NOTE: I'm not running Windows 8. On my Windows 7 system, the data directory is C:\ProgramData\MySQL\MySQL Server 5.5\data\)

MySQL InnoDB database restore using .frm files and ibdata files

Hi mistakenly I have deleted my MySQL database from Windos XP based PC (this database was used to host a Wiki service using Xampp package). Now I am trying to restore the data so that I can atleast retrieve the TEXT entered in the respective table of Mediawiki package.
After deletion I tried to recover the data using Minitool data recovery software and was able to recover the main schema folder containing .frm files, ib_logfile0, ib_logfile1 and ibdata1 (which was stored under C>xampp>mysql>data).
Now I am trying to restore the database so that I can take a SQL dump and use it accordingly. I have consulted some previous suggestions provided by the experts. Below are the links -
Restoring MySQL InnoDB files on Windows
Stackoverflow answers
But these did not help me very much, not sure what exactly I am missing from the instructions. At the end I was unable to start MySQL service and it failed with the below errors in log -
120823 12:17:04 [Note] Plugin 'FEDERATED' is disabled.
120823 12:17:04 InnoDB: The InnoDB memory heap is disabled
120823 12:17:04 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120823 12:17:04 InnoDB: Compressed tables use zlib 1.2.3
120823 12:17:04 InnoDB: Initializing buffer pool, size = 16.0M
120823 12:17:04 InnoDB: Completed initialization of buffer pool
120823 12:17:04 InnoDB: highest supported file format is Barracuda.
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/error-creating-innodb.html
120823 12:17:04 [ERROR] Plugin 'InnoDB' init function returned error.
120823 12:17:04 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
120823 12:17:04 [ERROR] Unknown/unsupported storage engine: InnoDB
120823 12:17:04 [ERROR] Aborting
Any help to recover from this situation will be highly appreciated. I am willing to provide some more data if required. [MySQL Server Version 5.5, xampp-win32-1.8.0-VC9]
Oh God finally it's solved :)
Actually I am a novice that's why I could not solve this quickly. Here is the workflow I followed.
I installed a fresh copy of MySQL server. Run Wizard config for transactional database.
I stopped MySQL from Services.msc
Then overwrote the ib* and *frm files (under the schema folder) in C/programdata/mysql/mysql server 5.5/data folder
Updated the my.ini in C/apps/mysql with the innodb_log_file_size=<actual size of iblogfile0>
ran the command mysqld --defaults-file="C:/apps/mysql/my.ini" --standalone --console --innodb_force_recovery=6
once the above completed closed cmd.exe
restarted MySQL service
Opened MySQL workbench and took a dump
Sorry to confuse you all. Thanks again. Let me know if anybody requires any clarity for the above steps.

Changing the data folder of MySQL database

I tried to change the data folder path of MySQL by changing the datadir parameter in the my.ini file. But when I restarted MySQL service again I get the following error :
Error 1067: the process terminated unexpectedly.
I checked the .err file, the following errors are present: (they are all about InnoDB)
120319 3:59:59 [Note] Plugin 'FEDERATED' is disabled.
120319 3:59:59 InnoDB: The InnoDB memory heap is disabled
120319 3:59:59 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120319 3:59:59 InnoDB: Compressed tables use zlib 1.2.3
120319 3:59:59 InnoDB: Initializing buffer pool, size = 75.0M
120319 3:59:59 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file .\ib_logfile0 is of different size 0 99614720 bytes
InnoDB: than specified in the .cnf file 0 39845888 bytes!
120319 3:59:59 [ERROR] Plugin 'InnoDB' init function returned error.
120319 3:59:59 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
120319 3:59:59 [ERROR] Unknown/unsupported storage engine: INNODB
120319 3:59:59 [ERROR] Aborting
You have to specify the right size for:
innodb_log_file_size=95M in your my.cnf or my.ini. It is specified as 38M currently I guess.
Also check from your data folder as how many ib_logfiles you have. If you have more than 2, specify also: innodb_log_files_in_group=2.
Is this on Windows? If so one could use a VHD as storage device for MariaDB/MySQL. I've done so to prevent loss of data whenever I install or update the DB software (in Wamp, Xampp, Mamp, Wampserver etc.)
In order to do so I created a VHD with diskpart and mount it in boot time to the data folder in the respective MariaDB or MySQL folder (moving the original to data.orig first and copying it back as soon the device is running)
I use this script to mount the vhd at boot:
diskpart /s "C:\ProgramData\DB\connectvdisk\attach_mariadb-data.diskpart"
where attach_mariadb-data.diskpart contains
select vdisk file="c:\ProgramData\DB\mariadb-daten.vhdx"
attach vdisk
and the vhdx was set to mount to the proper location in Disk Manager.
The script is executed at boot time (trigger: At Startup) with Task Scheduler running cmd.exe with the following as parameter
/c "C:\ProgramData\DB\connectvdisk\connect-vhd.cmd"
I hijacked the ProgramData folder for this kind of storage. On some systems I've moved the scripts and device to secondary storage (D:) to be sure it survives a OS reinstall.
This continues to work on Windows 11