Skip to content

Instantly share code, notes, and snippets.

@iamvivekkaushik
Last active May 13, 2020 05:46
Show Gist options
  • Select an option

  • Save iamvivekkaushik/6a72497326b7dab4c1222bdadfe55870 to your computer and use it in GitHub Desktop.

Select an option

Save iamvivekkaushik/6a72497326b7dab4c1222bdadfe55870 to your computer and use it in GitHub Desktop.
Install MySQL on Ubuntu 18.04

First Install MySQL on your ubuntu server

  sudo apt install mysql-server

Create new MySQL user

Login to MySQL and create a new user with the following command

  CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

change newuser and password with your desired username and password

Grant all privileges

  GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';

again, change the newuser with the user specified in the previous step.

Allow Connection to this User over the internet

  Grant ALL PRIVILEGES ON *.* TO 'newuser'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

Allow connection to MySQL server

Now you need to edit the mysql config file to allow connection to the MySQL server. Open the config file using the below command.

  cd /etc/mysql/mysql.conf.d/
  sudo nano mysqld.cnf

comment out the line below from the mysqld.cnf file with '#' symbol and save the file.

  bind-address = 127.0.0.1

Restart MySQL Server

  sudo service mysql restart

Note: Make sure port '3306' is open in your security group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment