Annexes:MySQL

De WikiFr

Déploiement de RPM

Téléchargez les RPM client, devel, shared, shared-compat et server pour votre OS et mettez-les dans /tmp.
Exemple pour l’installation d’une 5.6.22 :

[root@vmsqwarebox home]# cd /tmp
[root@vmsqwarebox tmp]# rpm -ivh MySQL-client-5.6.27-1.el6.x86_64.rpm
warning: MySQL-client-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[root@vmsqwarebox tmp]# rpm -ivh MySQL-devel-5.6.27-1.el6.x86_64.rpm
warning: MySQL-devel-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[root@vmsqwarebox tmp]# rpm -ivh MySQL-shared-5.6.27-1.el6.x86_64.rpm
warning: MySQL-shared-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-shared           ########################################### [100%]
[root@vmsqwarebox tmp]# rpm -Uvh MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm
warning: MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-shared-compat    ########################################### [100%]
[root@vmsqwarebox tmp]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm
warning: MySQL-server-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]

...
...

You will find that password in '/root/.mysql_secret'

...
...


Modifications post-installation

Mise en démarrage automatique :

[root@vmsqwarebox tmp]# chkconfig mysql on
[root@vmsqwarebox tmp]# service mysql start


Changement du mot de passe du user MySQL ‘root’ :

[root@vmsqwarebox tmp]# /usr/bin/mysql_secure_installation


Test de connexion:

[root@vmsqwarebox tmp]# mysql -S /var/lib/mysql/mysql.sock -uroot -pSqwareMys
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> Bye

Remise du user unix ‘mysql’ dans le groupe dba :
<pre>
[root@vmsqwarebox tmp]# id mysql
uid=503(mysql) gid=157(mysql) groupes=157(mysql)
[root@vmsqwarebox tmp]# usermod -Gdba,mysql mysql
[root@vmsqwarebox tmp]# id mysql
uid=503(mysql) gid=157(mysql) groupes=157(mysql),500(dba)


Quelques paramètres conseillés :

[root@vmsqwarebox tmp]# cat /etc/my.cnf
[mysqld]
skip-name-resolve
read_buffer_size = 3M
key_buffer_size = 128M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 32
myisam_recover_options = BACKUP
max_connections = 100
table_definition_cache = 400
sort_buffer_size = 32M
myisam_sort_buffer_size = 64M
innodb_buffer_pool_size = 1024M
join_buffer_size = 64M
tmp_table_size = 16M
innodb_thread_concurrency = 16
innodb_file_per_table = 1