How to install MySQL/MariaDb server in GCP Ubuntu Instance

f you are using Google Cloud Platform and trying to install MySQL server (MariaDB) on Ubuntu 16.04, you may frequently get some issues while trying to install.

You may get some error like the below one:

Errors were encountered while processing: mysql-server-5.7 mysql-serverE: Sub-process /usr/bin/dpkg returned an error code (1)

In this case, follow these steps to clean up the MySQL server installation.

Type the below command in the same order:

  • sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
  • sudo rm -r /etc/mysql/mysql.conf.d/
  • sudo mv /etc/mysql/debian.cnf /etc/mysql/debian.cnf.bak
  • sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7
  • sudo apt install mysql-server
  • sudo ln -s /etc/mysql/mysql.conf.d /etc/mysql/conf.d
  • sudo service mysql start


To check if MySQL is running properly or not, you can type below command to check status:

systemctl status mysql.service

or can use this command to know the version of MySQL

mysqladmin -p -u root version

Hope you found this post useful and it solved your problem!

I found this solution here: [Credits]

Post a Comment

0 Comments