Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

STEP 1. Enable MySQL Repository

Code Block
sudo yum -y localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

...

STEP 2. Install MySQL 5.7 Server

Code Block
sudo yum -y install mysql-community-server

...

STEP 3. Start MySQL Service

Code Block
sudo service mysqld start


STEP 4. Checking temporary password

Code Block
sudo grep 'A temporary password' /var/log/mysqld.log | tail -1

...

Change password by the pre-defined password above

Code Block
mysql_secure_installation 

Adding a mysql user account

Code Block
mysql -uroot -p<password>

#uninstall pluging to validate_password (not recommended)
uninstall plugin validate_password;

# below script is to create user account for local connection
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'user_password';

# below script is to create user account can conneect from 1.2.3.4
CREATE USER 'newuser'@'1.2.3.4' IDENTIFIED BY 'user_password';

# below script is to create user account for any connection
CREATE USER 'newuser'@'%' IDENTIFIED BY 'user_password';

Granting user permission

Code Block
mysql -uroot -p<password>

# grant privileges on a certain database
GRANT ALL PRIVILEGES ON database_name.* TO 'database_user'@'localhost';

# grant privileges on all the database in the system
GRANT ALL PRIVILEGES ON *.* TO 'database_user'@'localhost';

# grant full privileges on all the database in the system
GRANT ALL PRIVILEGES ON *.* TO 'database_user'@'localhost' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;mysqladmin -u root -p password <your password>



STEP 5. Initial MySQL Configuration

...

Note you can use the temporary password acquired at STEP 4.


STEP 6. /etc/my.cnf

Below is what I use in my server (i7 / RAM 32G) to run multiple server instances

Code Block
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


# added by Chun Kang - 2020-04-20
character-set-server = utf8mb4
collation-server = utf8mb4_bin

# wait_timeout=28800 #28.800
wait_timeout=1800 #1.800

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Added to support Confluence
default-storage-engine=INNODB
transaction-isolation=READ-COMMITTED
max_allowed_packet=256M
open_files_limit= 100000
max_connections = 100000
table_open_cache= 100000
binlog_format=row

explicit_defaults_for_timestamp = TRUE

innodb_buffer_pool_size = 12GB          # recommended to use 60-80% of whole RAM
innodb_log_file_size = 2GB              # recommended by confluence, 20% of innodb_buffer_pool_size
innodb_file_per_table = ON
innodb_large_prefix=ON
innodb_file_format=Barracuda