55

Can someone give me a clear explanation of the differences between mysql (command line tool), mysqladmin (client tool for performing administrative tasks) and mysqld (mysql server).

Preom
  • 1,680
  • 3
  • 15
  • 20

1 Answers1

72

You could easily find that out yourself by just reading the man pages about the three commands:

  • mysqld is the server executable (one of them)
  • mysql is the command line client
  • mysqladmin is a maintainance or administrative utility

They serve different purposes. There is not simply a "difference" between them. For different task you have different utilities. Just like you use a screwdriver for a screw and a hammer for a nail.

If you want to query a database server you need to connect to it using a client. The client connects to the server which serves the mysql service. If you need to do administrative adjustments in the server you need an administration utility.

Typically the server is started and stopped by the operating system it runs on, so at bootup and shutdown times. The clients (there are different types of clients) are started and used by users or programs handling with data inside the server. And the administrative staff uses the administrative tool to administer the servers on their systems.

arkascha
  • 41,620
  • 7
  • 58
  • 90
  • I'm not a linux guy. Could you tell what would happen if I type want to access command line client but accidentally type: mysqld -uroot -p with sudo privileges? – Horaciux Feb 26 '19 at 18:43
  • It would probably start the server daemon. – Rodney P. Barbati Jan 23 '20 at 17:04
  • As a beginner in SQL/databases/RDBMs, this is still really unclear. I am following a tutorial that uses "mysql.server" which I'm having trouble with, but the [reference manual](https://dev.mysql.com/doc/refman/8.0/en/mysql-server.html) says "mysql.server is the script name as used within the MySQL source tree. The installed name might be different (for example, mysqld or mysql). In the following discussion, adjust the name mysql.server as appropriate for your system." I haven't found a clear explanation of what this means without loads jargon! – FJC Jan 17 '22 at 13:55
  • @FJC As I understand it the "mysql.server" script offers control of the mysql server process. That might not be required on some platforms, namely Linux, since those systems already come with capable and standardized frameworks for service control. And indeed the reference manual you cite mentions right at the beginning in a prominent note: "For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, mysql.server and mysqld_safe are not installed because they are unnecessary." – arkascha Jan 17 '22 at 15:41
  • @FJC On Linux based systems (and similar systems) you usually do not directly start or stop a system service. Instead you use a controlling framework. Under Linux that would be the old init-System with the runlevels or systemd. Typically that means you control the server either automatically during system startup or shutdown, or explicitly by some command like `service mysql start`. Such command refers to a _service_ mysql, not an executable of the same name. – arkascha Jan 17 '22 at 15:44