✓ Solved

How to set up Mysql


I have an ubuntu 20.04 install and im trying to get mysql setup on it.
When following this tutorial:


I am told to use the following command:

sudo mysql_secure_installation

however when I use the command I get the foollowing error:

mysql_secure_instillation: command not found

I wish to set this up to be accessible from my site running on a different host (I may change this in the future) but I am fairly new to this, so if I need to do anything different to accomplish this please do point me in the direction of some resources.

Thank you very much!

2 Replies

Linode Staff

✓ Best Answer

The error output you're seeing indicates that mysql-server wasn't properly installed, making mysql_secure_installation an invalid command. This might happen if the apt update step was missed, or if there was a typo during the installation of MySQL server.

I spun up a new Ubuntu 20.04 LTS and was able to successfully run sudo mysql_secure_installation by running the following:

sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation

If you're going to be opening your database up to the internet for access from your site on another host, I'd recommend configuring your firewall to only allow connections from your site. Since the default firewall for Ubuntu 20.04 is UFW, this guide should prove useful:

Thank you,

This is probably something stupid that I'm doing again (I thought I performed all those steps but I must've made a typo)

now once entering the root password after running the command, I get the following error:

Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct