MySQL Fails to Start

Problems with the Windows version of XAMPP, questions, comments, and anything related.

MySQL Fails to Start

Postby ajax » 31. January 2023 21:48

This topic pertains to XAMPP for Windows. What I particularly like about XAMPP for Windows Portable is that I can implement a new version of XAMPP without making any changes to existing instances of XAMPP. As a result, I do have multiple version of XAMPP installed and available to run on my testing computers. Recently, while trying to run XAMPP Version 7.4.33 I've started to encounter frequent instances where MySQL cannot be started. Since most if NOT all of the websites I'm testing use MySQL databases this has the affect of making none of the websites installed on an instance of XAMPP accessible. BTW, just another reason why portable versions of XAMPP are so good.

For whatever reason, it might be worth offering that the error messages displayed by the XAMPP Control Panel when this happens are shown in the following.

https://www.dropbox.com/s/3ic5jmk4jdod19v/MySQLerrorStarting.jpg?dl=0

While I'd love to know what is causing the problem, especially if it is something I'm doing which can be prevented, I'm thinking that backup/recovery would be a big help in diminishing the severity of the problem. One idea is to make frequent copies (likely zip archives) of the MySQL portion of XAMPP. This hinges on the idea that the entire content of the MySQL folder could be replaced with a current backup without causing significant problems. In that, the database processing is entirely contained in the MySQL folder.

Note: Wordpress is a primary component of many of my websites, which depends heavily on SQL databases which in this case are managed by MariaDB rather than MySQL.

Therefore, is the idea of being able to separately backup and restore the content of the MySQL folder good or bad?
ajax
 
Posts: 35
Joined: 14. December 2010 17:57
Operating System: Windows 2000 Professional

Re: MySQL Fails to Start

Postby Froosh » 01. February 2023 01:28

My experience has been that recent versions of XAMPP for Windows run into database problems when the MySQL/MariaDB is not configured to run as a Windows Service. In my case, running as a Service works, and I no longer experience database issues.

In your situation, running as a Service might be possible, but only if you were to reconfigure the Windows Services to work with your desired XAMPP version. You could also possibly (not sure) accomplish this using a Junction point and switching that between the XAMPP versions, and having the Services *not* set to start automatically.

If you look at other threads related to database backups, and XAMPP, you will find that XAMPP does not have this capability. I believe this is primarily since XAMPP is comprised of a bundle of packages, and just deals with basic configuration and package version used for a particular XAMPP release. That said, backups can be automated using the Windows Task Scheduler or manually. A script, and mysqldump.exe or a file/folder copy would work for either approach.
User avatar
Froosh
 
Posts: 138
Joined: 27. March 2022 17:56
XAMPP version: 8.2.0
Operating System: Windows 11 Pro

Re: MySQL Fails to Start

Postby ajax » 01. February 2023 18:15

Very Interesting!

Maybe I need to elaborate a bit on my configuration. First, as mentioned, I run several versions of XAMPP on the same computer. It has been my observation that the primary thing that ties all of the components together is being in a sub-folder of a folder named XAMPP. Therefore each of my several versions of XAMPP is installed on the same secondary drive in a folder with a name such as "XAMPP7.4.33". Then the version I want to start up and use at any particular time has said folder renamed to "XAMPP". I've been using the supplied XAMPP Control Panel to start and stop both MySQL and Apache, which I likened to stating and stopping a Windows Service. I will have to admit that I do NOT know precisely what that control panel is actually doing. However, I can keep a single shortcut on my desktop that references the version located in the folder named XAMPP.

Another consideration that may be relevant is that I normally sign-on to and operate Windows with a user-id that does NOT have administrative privileges. Therefore, when I start the XAMPP Control Panel I use the "Run as Administrator" selection from the right click drop-down menu.

This method has worked just fine for many years now. However, in addition to getting a new release of XAMPP (Version 7.4.33) I have been switching back and forth between active versions more frequently partly because I'm trying to move websites running on older versions to the newer one. Note: I picked Version 7.4.33 because my shared hosting service does NOT yet use PHP 8.?. With that said, I have always been inclined to ponder what actually happens when using the "Stop" button on said control panel. If that is not what Windows would refer to as "CLOSE" then maybe something is left running that could interfere when trying to start a different version of MySQL from a different version of XAMPP Control Panel while still in the same Windows sign-on session.

I'd expect a Windows Service to run with Administrator Permissions but if there are other differences from what an application like XAMPP Control Panel can do I'm unaware of such.

Is it possible that when I want to change from running one version of XAMPP to another I should sign-out and then sign-in again before launching the XAMPP Control Panel again.

Also, I would assume that running my MySQL as a service would mean starting the module named "./XAMPP/mysql/bin/mysqld.exe". Yes?
ajax
 
Posts: 35
Joined: 14. December 2010 17:57
Operating System: Windows 2000 Professional

Re: MySQL Fails to Start

Postby Froosh » 02. February 2023 00:05

When you run the XAMPP Components from the XAMPP Contol Panel, they run as normal processes. I am assuming in this case that when you stop them from the Control Panel, or exit the Control Panel, it is not done cleanly. I do not know this for certain.

Note, in my XAMPP setup I don't use Junctions, but I do run MySQL and Apache as manually started Windows Services. I currently do use other XAMPP components. So, none of what I am indicated below has been tried, and may need tweaking...

    - If you use Junctions and Windows Services for at least MySQL, you would need to *manually* configure the mysql Windows Service, and any others you have set to run as a service (Apache, FileZilla, Mercury, Tomcat).
    - One time only
      - Configure the XAMPP components to run as Services
      - It is probably easiest done with everything in place in the c:\xampp folder, and using the XAMPP Control Panel run as an Administrator.
      - Once that is done, and with the services/applications not running, you could rename c:\xampp back to whatever version specific folder is appropriate for you. Note, I think you might also be able to do this using a registry script
      - Using the Winwow Services MMC (services.mmc), configure the XAMPP component Windows Services to start manually. XAMPP Control confitures them to run automatically. Once configured this way, the XAMPP component services can be started and stopped from the XAMPP Control Panel
    - Prior to running the XAMPP Control Panel, and starting any services or components of a particular version of XAMPP
      - Update the Junction for the home XAMPP folder (usually c:\xampp) to be a Junction to the actual specific XAMPP version folder, say "c:\XAMPP7.4.33".
      - I've created Junctions using the SysInternals Junction command utility. Junctions can also be created using the Windows "mklink" command from a command prompt
    - After configuring the c:\xampp Junction to point to the specific XAMPP version folder you want to run, you launch the XAMPP Control Panel, and start the components (services or applications)

Good luck.
User avatar
Froosh
 
Posts: 138
Joined: 27. March 2022 17:56
XAMPP version: 8.2.0
Operating System: Windows 11 Pro

Re: MySQL Fails to Start

Postby JJ_Tagy » 02. February 2023 00:40

Biggest reason that the database gets corrupted is because of how it shuts down. As a service, it shuts it down clean. Another way, which will help in your case since you don't want to run as a service, is to execute
Code: Select all
mysqladmin shutdown -uroot
from the control panel command prompt.
JJ_Tagy
 
Posts: 788
Joined: 30. January 2012 13:44
XAMPP version: 5.5.15
Operating System: Windows 10 Pro x64

Re: MySQL Fails to Start

Postby Froosh » 02. February 2023 16:25

That is good to know, and certainly something for XAMPP users to consider if they do not want to go through the extra trouble of setting up the Windows Services to start manually.

I added the suggested solution "mysqladmin shutdown -uroot" on the ApacheFriends xampp-control-windows github repository.
User avatar
Froosh
 
Posts: 138
Joined: 27. March 2022 17:56
XAMPP version: 8.2.0
Operating System: Windows 11 Pro

Re: MySQL Fails to Start

Postby Altrea » 02. February 2023 19:56

problem is this will not work if the root user password gets changed.
A better solution would be to add a specific xampp database user which only has shutdown rights and use this user for mysqladmin command.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: MySQL Fails to Start

Postby ajax » 04. February 2023 02:10

Sounds like pretty relevant information.

Here is what I've tried which notably does NOT involve any switching of XAMPP releases. This happens to be XAMPP Version 7.4.33 on Windows 10 if that matters.

    I can start the control panel using "Run As Administrator" method.
    Then Select the Start button for MySQL. Appears to start MySQL.
    Then when I select the Shell button on the control panel it asks to set up a .bat file to be used for starting the shell (i.e., command prompt). This only happens first time after which it seems to reuse the .bat file that was previously created. Looking at resulting .bat file it appears to customize environment for running XAMPP.
    As it happens, on my Windows computers I use the name "Root" for the user that has administrative privileges. The Shell opens with a prompt that says "root@NEPTUNE t:\xampp" where Neptune is the Windows host name.
    I then type in the command "mysqladmin shutdown". Then on the control panel MySQL appears to be stopped. Interestingly, the same error message which I included in the original post for this topic gets displayed. In that, the message that starts with "Error: MySQL shutdown unexpectedly ...".

However, what is different now from when I previously received that message is that I can restart MySQL and it seems to start normally. This suggests that the database is still usable (which was NOT the case previously).

If the problem previously had to do with the control panel NOT doing a complete shutdown of MySQL as a result of selecting the Stop button. Then this approach might be an improvement.

What I find odd is that the control panel itself can be closed without shutting down MySQL. I think the idea is that if MySQL wasn't completely shutdown, then when it is restarted with a different instance of XAMPP things (i.e., MySQL database) could gets messed up. Would be nice if there were a way to verify that MySQL has been completely shutdown.
ajax
 
Posts: 35
Joined: 14. December 2010 17:57
Operating System: Windows 2000 Professional

Re: MySQL Fails to Start

Postby Froosh » 04. February 2023 15:08

I then type in the command "mysqladmin shutdown". Then on the control panel MySQL appears to be stopped. Interestingly, the same error message which I included in the original post for this topic gets displayed. In that, the message that starts with "Error: MySQL shutdown unexpectedly ...".


I am going to guess that this happens because to the Control Panel, MySQL did shutdown unexpectedly. It has know way, that I can think of, to know that a user shutdown the process from a terminal. Which I guess, is expected behavior...
User avatar
Froosh
 
Posts: 138
Joined: 27. March 2022 17:56
XAMPP version: 8.2.0
Operating System: Windows 11 Pro


Return to XAMPP for Windows

Who is online

Users browsing this forum: tysonzach and 160 guests