Installazione MariaDB standalone

Da wiki.gienne.cloud.

Installazione:


Prerequisito:


File mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz presente sotto cartella /mysql o /misc/software/oracle/mysql

Cartella /opt/mysql con diritti di accesso lettura e scrittura ad utente Mysql.

Il file my.cnf nella cartella /mysql o /misc/software/oracle/mysql


Creazione cartelle:


mkdir -p /opt/mysql/etc 
mkdir -p /opt/mysql/dump 
mkdir -p /opt/mysql/tmp 
mkdir -p /opt/mysql/etc 
mkdir -p /opt/mysql/pid 
mkdir -p /opt/mysql/logs 
mkdir -p /opt/mysql/log 
mkdir -p /opt/mysql/binlog 
mkdir -p /opt/mysql/data 
mkdir -p /logs/mysql 

DA RIVEDERE:

echo export MYSQL_HOME=/opt/mysql >> /home/mysql/.profile echo PATH=$PATH:$MYSQL_HOME/bin >> /home/mysql/.profile echo export PS1='\h:\w\$' >> /home/mysql/.profile



Copia software e rimozione file di installazione:


Dipende da come si vuole e dove si vuole mettere il software.


cd /mysql


In Maserati per il momento è sotto:

cd /misc/software/oracle/mysql


Copiare solo il file CNF relativo alla macchina che si sta facendo

cp my.cnf /opt/mysql/etc



cp mariadb-10.3.9-linux-x86_64.tar.gz /opt/mysql

cd /opt/mysql 
tar -xvzf mariadb-10.3.9-linux-x86_64.tar.gz 
rm /opt/mysql/mariadb-10.3.9-linux-x86_64.tar.gz



Creazione collegamenti (lo standard definito in Maserati con il gruppo Unix definisce di lasciare il nome della directory con nome originale e usare i collegamenti simbolici.

mkdir -p /opt/mysql/etc 
mkdir -p /opt/mysql/dump 
mkdir -p /opt/mysql/tmp 
mkdir -p /opt/mysql/etc 
mkdir -p /opt/mysql/pid 
mkdir -p /opt/mysql/logs 
mkdir -p /opt/mysql/log 
mkdir -p /opt/mysql/binlog 
mkdir -p /opt/mysql/data 
mkdir -p /logs/mysql 


ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/bin /opt/mysql/bin 
ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/docs /opt/mysql/docs 
ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/include /opt/mysql/include 
ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/lib /opt/mysql/lib 
ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/man /opt/mysql/man 
ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/share /opt/mysql/share 

ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/scripts /opt/mysql/scripts

ln -s /opt/mysql/mariadb-10.3.9-linux-x86_64/support-files /opt/mysql/support_files 



./scripts/mysql_install_db --basedir=/opt/mysql --defaults-file=/opt/mysql/etc/server.cnf


mysqld --defaults-file=/opt/mysql/etc/server.cnf --basedir=/opt/mysql & 

/opt/mysql/bin/mysqladmin -u root password '****'


CREATE USER 'admin'@'%' IDENTIFIED BY '****'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;

  1. !/bin/sh

mysql -uroot -p**** -h127.0.0.1 -e "shutdown;"




Nel momento della creazione del primo db viene generata una password dell'utente locale "root".

Per recuperarlo bisogna aprire il file di log.


Per avviare a mano il DB esempi di avvio:


mysqld --defaults-file=/opt/mysql/etc/server.cnf --basedir=/opt/mysql &



Per collegarsi al'istanza DB:


mysql -h 127.0.0.1 -u root -p


Per settare la password di root (da mysql shell sul master): SET PASSWORD = '****';


FILE CNF:

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.2 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.2]
#skip-grant-tables


#Personal Parameters

character_set_client=utf8                 
character_set_server=utf8                   
max_connections = 505                                                                                                                         
max_heap_table_size = 64M                                                                                                                     
sort_buffer_size = 64M                                                                                                                        
join_buffer_size = 64M                                                                                                                        
query_cache_size = 256M                                                                                                                       
query_cache_limit = 8M                                                                                                                        
max_allowed_packet = 64M