Search code examples
ubuntuversionupdatesmosquitto

How to update mosquitto to latest version in Ubuntu


I have installed mosquitto in ubuntu using command:

sudo apt-get install mosquitto

The mosquitto installed is version 1.6.9.

mosquitto version 1.6.9

mosquitto is an MQTT v3.1.1 broker.

Usage: mosquitto [-c config_file] [-d] [-h] [-p port]

 -c : specify the broker config file.
 -d : put the broker into the background after starting.
 -h : display this help.
 -p : start the broker listening on the specified port.
      Not recommended in conjunction with the -c option.
 -v : verbose mode - enable all logging types. This overrides
      any logging options given in the config file.

See http://mosquitto.org/ for more information

In order to update the mosquitto to latest version, I first uninstalled it and then ran command sudo apt-get update and then reinstalled the mosquitto but the version was still the same.

How can I update mosquitto to latest version.?


Solution

  • If you want a more recent version of mosquitto but you are on an old version of Ubuntu then by reading the official download page here you can find that there is more than one approach to install the latest mosquitto version :

    1. Compiling and building directly from source, i wouldn't recommend doing this (especially for beginners).
    2. Using the mosquitto-dev PPA.
    3. Using snap packages instead of apt by simply running sudo snap install mosquitto

    However i think the best way to go is by using the mosquitto-dev PPA as building mosquitto from source take more time and effort, and using snap involves more steps to get it up and running.

    So.. First uninstall the old mosquitto version:

    sudo apt autoremove mosquitto
    

    then you need to add mosquitto-dev PPA to your sources list :

    sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa 
    sudo apt-get update
    

    Finally, install mosquitto:

    sudo apt install mosquitto 
    

    Verify your installation by simply running mosquitto --help, the output should be something like this :

    mosquitto version 2.0.10
    
    mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.
    
    Usage: mosquitto [-c config_file] [-d] [-h] [-p port]
    
     -c : specify the broker config file.
     -d : put the broker into the background after starting.
     -h : display this help.
     -p : start the broker listening on the specified port.
          Not recommended in conjunction with the -c option.
     -v : verbose mode - enable all logging types. This overrides
          any logging options given in the config file.
    
    See https://mosquitto.org/ for more information.
    

    Congrats Now you have the latest release installed.