The easiest way in Linux to optimize MYSQL data server performance, is to use mysqltuner script.
MySQLTuner is a script written in perl that will assist you with your MySQL configuration & make recommendations for increased performance and stability.
The simplest is to download the latest MySQLTuner version in plain text to your server using wget mysqltuner.pl command:
wget mysqltuner.pl chmod 0700 mysqltuner.pl ./mysqltuner.pl
Another easy method is to install the mysqltuner application, since is already added to the Ubuntu repositories. Below is an example of an installation in Ubuntu version 18.4
sudo apt-get update && sudo apt-get -y upgrade sudo apt-get install mysqltuner sudo mysqltuner
As a result, you should get recommendations like this:
-------- Recommendations ---------- General recommendations: Control warning line(s) into /var/log/mysql/error.log file Control error line(s) into /var/log/mysql/error.log file MySQL started within last 24 hours - recommendations may be inaccurate Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1 Adjust your join queries to always utilize indexes Variables to adjust: join_buffer_size (> 1.0M, or always use indexes with joins)