[MDEV-19358] Remove service registration code from mysqld.exe Created: 2019-04-29  Updated: 2020-07-01

Status: Open
Project: MariaDB Server
Component/s: Platform Windows
Fix Version/s: None

Type: Task Priority: Major
Reporter: Vladislav Vaintroub Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: beginner-friendly

Issue Links:
Relates
relates to MDEV-15693 Stop packaging data directory into ZIPs Closed
relates to MDEV-19354 Rename Windows service name to MariaDB Closed

 Description   

Windows specific functionality "mysqld --install" , "mysqld --remove" should not be used anymore. This functionality is deprecated since we have mysql_install_db.exe, i.e 5.5. mysql_install_db.exe does the service registration and more.

Removing a service is a simple call to "sc delete <service_name>".

Also the logic "if mysqld.exe was started without parameters, lookup for MySQL service name and start it, if exists", this should be removed.



 Comments   
Comment by Sergei Golubchik [ 2019-08-06 ]

couldn't it break existing installations that use, say, "mysqld.exe was started without parameters" ?

Comment by Michael Widenius [ 2019-09-17 ]

What is the benefit for removing the options ?
Just because mysql_install_db can do it, doesn't mean that they should be removed (as some users may still use the old options)

Comment by Vladislav Vaintroub [ 2019-09-17 ]

serg, mysql_upgrade_service would take care of that, iirc already does.
monty, we do not package prebuilt datadir anymore, and do not have any other tool that does bootstrapping, other than mysql_install_db.exe . So "--install" just does not work . Also it did extremely trvial stuff that sc.exe was capable of, since maybe Windows 2000, or NT.

Besides, "mysqld --install" would run service as LocalSystem account, the most powerful Windows account, comparable to Unix root, which is a security problem. mysql_install_db,exe, on the other hand, makes mysqld run under the least privileged Windows service account NetworkService, and it has to set the ACL of the datadir explicitly to make files writable for NetworkService.

Comment by Dominique Ottello [ 2020-07-01 ]

I agree with "mysqld.exe --remove myservice" which can be replaced by the Windows command "sc delete myservice", but I absolutely don't agree with the removal of "mysqld.exe --install-manual myservice" that nothing replaces at the moment.
You say that mysql_install_db.exe and/or mysql_upgrade_service.exe are the replacement tools for "mysqld.exe --install-manual myservice", let me doubt it!
Can these tools only install a service without creating datadir and without creating a my.ini file?
Can these tools do exactly the same thing as :
mysqld.exe --install-manual wampmariadb64 --defaults-file=E:\wamp64\bin\mariadb\mariadb10.5.4\my.ini"

Otomatic - Dominique Ottello
Wampserver Developer

Comment by Vladislav Vaintroub [ 2020-07-01 ]

Otomatic. "sc create" can do this, can't it? Here is an old post of my colleague Chris
https://www.chriscalender.com/create-mariadb-windows-service/

The question is why do you want to run server without data directory. How do you bootstrap (create system tables), with the good old way?

Comment by Dominique Ottello [ 2020-07-01 ]

sc create wampmariadb64 binPath="E:\wamp64\bin\mariadb\mariadb10.5.4\bin\mysqld.exe --defaults-file=E:\wamp64\bin\mariadb\mariadb10.5.4\my.ini"
creates the service, apparently with the same parameters as via mysqld.exe --install-manual, but the service won't start.

Comment by Vladislav Vaintroub [ 2020-07-01 ]

Did you read that post attentively ?

You need to add service name at the end of binPath

"E:\wamp64\bin\mariadb\mariadb10.5.4\bin\mysqld.exe --defaults-file=E:\wamp64\bin\mariadb\mariadb10.5.4\my.ini wampmariadb64"

How do you think server would know that it is started as which service? It derives it from the last command line parameter

Comment by Dominique Ottello [ 2020-07-01 ]

data directory is created when installing different versions of MariaDB and, to switch from one version to another the actions are :

  • Stop service version A
  • Deleting service version A
  • Create service version B
  • Start service version B
Comment by Vladislav Vaintroub [ 2020-07-01 ]

Why do you delete and recreate the service ? What's the point?

Comment by Dominique Ottello [ 2020-07-01 ]

I didn't read the message "attentively" because it was changed after I read it...

After rereading, this:
sc create wampmariadb64 binpath="E:\wamp64\bin\mariadb\mariadb10.5.4\bin\mysqld.exe --defaults-file=E:\wamp64\bin\mariadb\mariadb10.5.4\my.ini wampmariadb64"
works well.

Comment by Dominique Ottello [ 2020-07-01 ]

> Why do you delete and recreate the service ? What's the point?
Because they are different versions of MariaDB and the installation paths of these versions are different.
For example, currently I have five versions of mariaDB: 10.1.45, 10.2.32, 10.3.23, 10.4.13, 10.5.4 and to switch from one version to another it is necessary to recreate the service that always has the same name.

Comment by Vladislav Vaintroub [ 2020-07-01 ]

I meant, reading "Chris' blog post" attentively . this blog post has not changed since 2012. It describes the very same problem you just had, gives an explanation, why binpath should add the servicename at the end.

Also note you can't always switch versions by simply restarting with new executables. if you upgrade from 10.4 to 10.5 for example, you need to stop the server with "innodb slow shutdown" (--innodb-fast-shutdown=0), and you likely need to run
mysql_upgrade after major version switch for system tables upgrade.

And mysql_upgrade_service takes care of all that, given that executables for the new version are in a different path. and of course, it also takes care of changing service's binPath.

Comment by Vladislav Vaintroub [ 2020-07-01 ]

So, would it be correct to state that you were requesting that "mysqld --install" should continue to live, to manually / partially replicate the logic of mysql_upgrade_service? Why not just to use mysql_upgrade_service as-is?

Comment by Dominique Ottello [ 2020-07-01 ]

> Why not just to use mysql_upgrade_service as-is?
Because:
E:\wamp64\bin\mariadb\mariadb10.4.13\bin>mysql_upgrade_service --service=wampmariadb64
FATAL ERROR: Not a valid MySQL service

E:\wamp64\bin\mariadb\mariadb10.5.4\bin>mysql_upgrade_service --service=wampmariadb64
FATAL ERROR: Not a valid MySQL service

While it works perfectly for more than fifteen years with mysqld.exe --install-manual and --remove for MariaDB from 5.5.62 to 10.5.4 and for MySQL from 5.1.72 to 8.0.20

Comment by Vladislav Vaintroub [ 2020-07-01 ]

Your solution or upgrade just does not work, on the reason outlined above.
If you want to file a bug for mysql_upgrade_service, I might happily accept it. Or, you can try to replicate whatever mysql_upgrade_service is doing, poorly

Generated at Thu Feb 08 08:51:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.