ESET Online Help

Search English
Select the category
Select the topic

MySQL installation and configuration

Installation


warning

Make sure to install a supported version of MySQL Server and ODBC Connector.

If you have already installed and configured MySQL, proceed to Configuration.

1.Add the MySQL repository:

Debian, Ubuntu

Run the following commands in the Terminal:

a)wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

b)sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb

You can select the versions of components that you want to install during the package installation. We recommend that you select the default options. See also Adding the MySQL APT Repository.

CentOS, Red Hat

Adding the MySQL Yum Repository

OpenSuse, SUSE Linux Enterprise Server

Adding the MySQL SLES Repository

2.Update your local repository cache:

Debian, Ubuntu

sudo apt-get update

CentOS, Red Hat

sudo yum update

OpenSuse, SUSE Linux Enterprise Server

sudo zypper update

3.MySQL installation differs depending on the Linux distribution and version used:

Linux distribution:

MySQL Server installation command:

MySQL Server advanced installation:

Debian, Ubuntu

sudo apt-get install mysql-server

Installing MySQL from Source with the MySQL APT Repository

CentOS, Red Hat

sudo yum install mysql-community-server

Installing MySQL on Linux Using the MySQL Yum Repository

OpenSuse, SUSE Linux Enterprise Server

sudo zypper install mysql-community-server

Steps for a Fresh Installation of MySQL

Download MySQL Community Server for a manual installation.

Configuration

1.Open the my.cnf configuration file in a text editor:

sudo nano /etc/my.cnf

If the file is not present, try /etc/mysql/my.cnf or /etc/my.cnf.d/community-mysql-server.cnf or /etc/mysql/mysql.conf.d/mysqld.cnf.

2.Find the following configuration in the [mysqld] section of the my.cnf configuration file and modify the values:


note

Create the [mysqld] section if it is not present in the file.

If the parameters are not present in the file, add them to the [mysqld] section.

To determine your MySQL version, run the command: mysql --version

 

Parameter

Comments and recommended values

MySQL version

max_allowed_packet=33M

 

All the supported versions.

log_bin_trust_function_creators=1

 

Alternatively, you can disable the binary logging: log_bin=0

Supported 8.x versions

innodb_log_file_size=100M

 

The multiplication of values of these two parameters must be at least 200.

The minimum value for innodb_log_files_in_group is 2 and maximum value is 100; the value also has to be integer.

Supported 8x versions

5.7

5.6.22 (and later 5.6.x)

innodb_log_files_in_group=2

innodb_log_file_size=200M

Set the value to at least 200M, but not more than 3000M.

5.6.20 and 5.6.21

3.Press CTRL + X and type Y to save changes and close the file.

4.Restart the MySQL server and apply the configuration (in some cases, the service name is mysqld):

sudo systemctl restart mysql

5.Set up MySQL privileges and password (this step is optional and may not work for some Linux distributions):

a)Reveal the temporary MySQL password: sudo grep 'temporary password' /var/log/mysql/mysqld.log

b)Copy and save the password.

c)Set a new password by following one of these options:

Run /usr/bin/mysql_secure_installation and type the temporary password. Then you will be prompted to create a new password.

Run mysql -u root -p and type the temporary password. Run ALTER USER 'root'@'localhost' IDENTIFIED BY 'strong_new_password'; to change the root password (replace strong_new_password with your password) and type Quit.

See also Improve MySQL Installation Security in the MySQL Reference Manual.

6.Verify that the MySQL server service is running:

sudo systemctl status mysql