MYSQL CHANGE PASSWORD

1
2
3
4
5
6
7
/etc/init.d/mysql stop
/usr/sbin/mysqld --skip-grant-tables
mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('votre_nouveau_mot_de_passe');
mysql> FLUSH PRIVILEGES;
mysql> exit
/etc/init.d/mysql start
1
2
3
// création user grant all
CREATE USER [IF NOT EXISTS] 'monadmin'@'%' IDENTIFIED BY 'monpass';
GRANT ALL  ON  *.* TO 'monadmin'@'%';

TUNNEL SSH

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ssh-keygen -t rsa -b 4096      // création clef ssh ( si pas déjà fait)
 
ssh  user@dev.monserveur.com  <-password // première connexion serveur relais manuelle
 
ssh-copy-id root@ monserveur.com  // copie clef
 
dans sshd_config ajouter :  GatewayPorts yes
/etc/init.d/ssh restart  //(debian)
 
ssh -R 4444:localhost:80 user@dev.monserveur.com
en se connectant sur dev.monserveur.com:4444 c'est localhost:80 qui répond.
 
autossh   -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3"  -R 4444:localhost:80 user@dev.monserveur.com
même chose mais en tache de fond avec reconnexion automatique
 
Lancement au boot ajouter un fichier /etc/systemd/system/autossh-tunnel.service
[Unit]
Description=AutoSSH tunnel service local 80 port 4444 dev.monserveur.mobi
After=network.target
 
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 4444:localhost:80 root@dev.monserveur.mobi
Restart=always
User=pi
 
[Install]
WantedBy=multi-user.target
 
puis:
sudo systemctl start autossh-tunnel.service
sudo systemctl stop autossh-tunnel.service
sudo systemctl enable autossh-tunnel.service  pour démarrage auto

https://wiki.archlinux.fr/Autossh

NEXTCLOUD pb update

Dans le .htaccess mettre en commentaires les lignes :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<IfModule mod_php5.c>
  #  php_value upload_max_filesize 511M
  #  php_value post_max_size 511M
  # php_value memory_limit 512M
  # php_value mbstring.func_overload 0
  # php_value always_populate_raw_post_data -1
  # php_value default_charset 'UTF-8'
  # php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
   # php_value upload_max_filesize 511M
   # php_value post_max_size 511M
   # php_value memory_limit 512M
   # php_value mbstring.func_overload 0
   # php_value default_charset 'UTF-8'
   # php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
 
<IfModule mod_dir.c>
   # DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
 # Options -Indexes

Dans quelques cas, ajouer au my.cnf ou mariadb.conf.d/50-server.cnf (erreurs oc_addressbooks)

innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=true

NEXTCLOUD après install

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
MariaDB version >13
my.cnf -> innodb_file_per_table=1
base de données -> CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
 
Dans le répertoire de l'install Nextcloud :
sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true"
sudo -u www-data php occ maintenance:repair
 
 
php.ini
memory_limit = 512M
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
 
apache.conf
<IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
 </IfModule>
 
a2emod http2 <-- activation de http2 dans Apache

NEXTCLOUD déplacer data

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo -u www-data php /path/to/nextcloud/occ maintenance:mode --on
mkdir -p /new/path/to/data
cp -a /path/to/data/. /new/path/to/data
chown -R www-data:www-data /new/path/to/data
 
/path/to/nextcloud/config/config.php  --> 'datadirectory' => '/new/path/to/data',
 
// Modif contenu de la Table
oc_storages id='local::/new/path/to/data/' --> id='local::/path/to/data/'
 
sudo -u www-data php /path/to/nextcloud/occ maintenance:mode --off
 
//Si tout est bon :
rm -R /path/to/data

SELECT INTO OUTFILE droits MySQL MariaDB

1
2
3
4
SELECT customer_id, firstname, surname INTO OUTFILE '/home/exportdata/customers.txt'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  LINES TERMINATED BY '\n'
  FROM customers;
1
2
3
4
5
6
7
8
chown mysql:mysql /home/exportdata/
chmod 777 /home/exportdata/
 
edit /etc/systemd/system/mysqld.service
ProtectHome=false
systemctl daemon-reload
/etc/init.d/mysql stop
/etc/init.d/mysql start