Fixing “mysql-community-server depends on libmecab2” During MySQL Installation on Ubuntu
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
- 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
- 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
- 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
- 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
- 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.