How to Install Latest MySQL Server on AWS EC2 Ubuntu 18.04

Install MySQL Server

To install the MySQL server, you must update your Linux packages system first, type:
sudo apt update
Then install the MySQL Server package:
sudo apt-get install mysql-server
MySQL prompt asking you to proceed install, then type: Y

Set Password on Root User

Please note that the MySQL root user is unsecured you need to provide a secure password for the root user once you deployed on production. To do this, run this command on your terminal:
$ sudo mysql
Next, we need to check which authentication method of each MySQL user, type command:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
You can see that the root user doesn’t have authentication_string using the auth_socket plugin. To configure the root account to authenticate with a password, run the following ALTER USER command:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Please note, make sure don’t forget to change the password.
Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and your new changes will take effect immediately:
mysql> FLUSH PRIVILEGES; 
Once you confirm this on your own server, you can exit the MySQL shell:

mysql> exit

Testing MySQL database

It doesn’t matter how you installed the MySQL Server it should have started running automatically after install. To check its status by typing command:
$ sudo service mysql status
To start the MySQL server if not running, type command:
$ sudo service mysql start
Then to stop the MySQL server running, type command:
$ sudo service mysql stop
And you can reload the MySQL server by typing the command:
$ sudo service mysql reload 

Comments

Popular posts from this blog

To install the mysql driver manually in Dbeaver

Can't connect to Remote MySQL Server (10061) to Ubuntu