Fading Coder

An Old Coder’s Final Dance

You are here: Home > Tech > Content

Fixing “mysql-community-server depends on libmecab2” During MySQL Installation on Ubuntu

Tech 2

When installing MySQL from Oracle’s .deb packages on Ubuntu, dpkg can leave the server unconfigured if a required library (libmecab2) isn’t present. This typically shows up when installing multiple local packages in one go.

Example install command (local .deb files):

sudo dpkg -i ./mysql-common_*.deb \
             ./mysql-community-client_*.deb \
             ./mysql-client_*.deb \
             ./mysql-community-server_*.deb \
             ./mysql-server_*.deb

If libmecab2 isn’t installed, dpkg reports an unmet dependency and stops configuring mysql-community-server:

dpkg: dependency problems prevent configuration of mysql-community-server:
 mysql-community-server depends on libmecab2 (>= 0.996-1.3); however:
  Package libmecab2 is not installed.

Because the server never finished configuring, trying to connect fails with a missing socket error:

mysql -u root -p
# ...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Below are two ways to resolve this depending on whether you want to continue with Oracle’s packages or switch to Ubuntu’s MySQL packages.

Option A: Satisfy the libmecab2 dependency and complete the install

  1. Let APT resolve dependencies for local .deb files (preferred over dpkg):
sudo apt update
sudo apt install ./mysql-common_*.deb \
                 ./mysql-community-client_*.deb \
                 ./mysql-client_*.deb \
                 ./mysql-community-server_*.deb \
                 ./mysql-server_*.deb
  1. If you already used dpkg and are in a half-configured state, install the missing library and fix dependencies:
sudo apt update
sudo apt install libmecab2
sudo apt -f install
  1. If libmecab2 can’t be found, enable the Universe repository and retry:
sudo add-apt-repository universe
sudo apt update
sudo apt install libmecab2
sudo apt -f install
  1. If you're Ubuntu release lacks a new enough libmecab2 in its repositories, add the official MySQL APT repo so APT can fetch compatible dependencies:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.26-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.26-1_all.deb
sudo apt update
sudo apt install libmecab2
sudo apt -f install
  1. Start the server (if not already running) and verify you can connect:
sudo systemctl restart mysql
mysql -u root -p

Option B: Remove the partial install and use Ubuntu’s mysql-server packages

If you prefer to instal the Ubuntu-packaged MySQL (which doesn’t require the Oracle mysql-community-server dependency chain), clean up the broken state and install from Ubuntu’s repos. Note: removing /var/lib/mysql will delete existing databases.

sudo systemctl stop mysql || true

sudo apt-get purge -y 'mysql-*' 'mariadb-*' 'percona-*'
sudo apt-get autoremove --purge -y
sudo rm -rf /etc/mysql /var/lib/mysql

sudo apt-get update
sudo apt-get install -y mysql-server mysql-common

Then connect to the server and confirm it’s running:

mysql -u root -p

You should see the MySQL monitor prompt with the server version reported by Ubuntu’s packages.

Tags: MySQL

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.