44
Top 15 MySQL parameters for beginners Aleksandrs Asafovs

Top 15 MySQL parameters

Embed Size (px)

Citation preview

Top 15 MySQL parameters for beginners

Aleksandrs Asafovs

Certified Ethical Hacker(CEH)

MySQL 5 Database Administrator

Oracle Database 11g Administrator Certified MasterOracle9i Database Administrator Certified ProfessionalOracle Database 10g Administrator Certified ProfessionalOracle Database 11g Administrator Certified Professional

Oracle9i Database Administrator Certified Professional - Special Accreditation: Managing Oracle9i on LinuxOracle RAC 11g Release 2 and Grid Infrastructure Administration

Oracle Database 10g Real Application Clusters Administrator Certified Expert

Oracle Application Server 10g Administrator Certified AssociateOracle Weblogic Server 11g: System Administration I

About me

My name is Aleksandrs AsafovsWorking with Oracle for over 15 years

MySQL 5 years

Certificate experts 200+

Competence

5

Data Integrity

Others

Performance schema

Security

InnoDB

Mistakes

Backup

First parameter

s

6

"sorry something went wrong"

7

• Choose the right configuration file• Choose the right mysql option group• [mysql] [mysqld] [mysqladmin]

"sorry something went wrong"

8

• incorrect memory configuration server with 4Gb RAM

max_connections x (sort_buffer_size +read_rnd_buffer_size + join_buffer_size + read_buffer_size + thread_stack + (tmp_table_size or max_heap_table_size)) / 4

151 x (128 MB + 256 KB + 128 MB +128 MB + 192 KB + 16 MB) / 4=15G

151 x (2 MB + 256 KB + 128KB +128 KB + 256KB  + 16 MB) / 4=708M

"sorry something went wrong"

9

• Do not write parameters twice()

Backup

Backup

• mysqldump• filesystem backup• filesystem snapshot• Percona XtraBackup(GPL license)

Backup

Purge old binary logs after this number of days

• log_bin

•expire_logs_days

Enable binary logging. The server logs all statements that change data to the binary log, which is used for backup

and replication.

13

Backup

Security

14

15

skip_networking=1

bind_address=127.0.0.1

SecurityAccess to database

https://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_skip-networking

16

SecurityAccess to database

SELECT load_file("/etc/passwd");

17

SELECT load_file("/etc/passwd");local_infile=0 orsecure_file_priv=/tmp/

SecurityLocal security

Security

GRANT ALL ON test.* TO 'tomas'@'localhost';Tomas

'tomas'@'localhost'Test

Security

20

Security

21

Password Validation Pluginplugin-load=validate_password.so

Security

22

Security

23

Security

Performance schema

24

Performance schema

25

Performance schema

26

Performance schema

27

Performance schema

Demo

Performance schema

• performance_schema=0(OFF) to disbale it

InnoDB

30

InnoDB

•innodb_buffer_pool_size• innodb_log_file_size = 30 -60 minutes

innodb_log_file_size = 32 – 512M

InnoDB Undo mysql 5.7

innodb_undo_tablespaces = innodb_undo_directory=/SSD/

https://dev.mysql.com/doc/refman/5.7/en/innodb-undo-tablespace.html

Data Integrity

33

34

SQL_MODE

SQL_MODE

SQL_MODE

Others

37

Others

38

thread_cache_size determines the number of threads that the server can store

for reuse.

thread_cache_size efficiency100 -((Threads_created/Connections) * 100)

Others

39

40

query_cache_size

Others Query Cache

key_buffer_size (MyISAM) # Set to 5 - 25 %

cache mechanism to keep the most frequently accessed table

blocks in memory:

Others

miss rate= Key_reads / Key_read_requests =  36627/222229559 = 0.001efficiency = 1- miss rate = 0.999

Others[mysql]

prompt=\\u@\\h [\v] [\\d]>\\_

Conclusion

https://tools.percona.com/

Choose Which Version of MySQL to Install

Thank You!

Aleksandrs [email protected]

Q & A