IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Administration MySQL Discussion :

Probleme de syntaxe mysql


Sujet :

Administration MySQL

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 5
    Points : 4
    Points
    4
    Par défaut Probleme de syntaxe mysql
    bonjour. je suis sur un serveur linux fedora 6, mysql-5.0.27-1, apache 2.2.3-5, php-5.1.6-3. quand je lance les script suivants, voici les erreurs en sortie:

    #!/bin/sh -x

    SQLUSER="xxxx"
    SQLPASS="yyyy"
    SQLBASE="proxy"
    SQLCMD="mysql -u$SQLUSER -p$SQLPASS $SQLBASE"

    TBLEXT="date --date=yesterday +%Y%m"


    #################################################
    #########Fonctions d'archivage
    #################################################

    function create_proxyaccess () {
    if [ -z $($SQLCMD -ss -e "SHOW tables like 'proxyaccess$TBLEXT'") ]; then
    echo creation de la table proxydenied$TBLEXT
    $SQLCMD -e "CREATE TABLE proxyaccess$TBLEXT (date datetime NOT NULL,proxy char(6) NOT NULL,user char(25) NOT NULL,IP char(15) NOT NULL,fqdn char(64) NOT NULL,url text NOT NULL,http_status int(11) NOT NULL,squid_status char(25) NOT NULL,method char(8) NOT NULL,reqtime int(11) NOT NULL,taille int(11) NOT NULL) ENGINE=ARCHIVE DEFAULT CHARSET=latin1"
    fi
    }

    function archive_proxyaccess () {
    echo archivage des logs du proxy \(proxyaccess$TBLEXT\)
    create_proxyaccess
    $SQLCMD -e "insert into proxyaccess$TBLEXT select * from proxyaccess where date < date_format(now(),'%Y-%m-%d');delete from proxyaccess where date < date_format(now(),'%Y-%m-%d');optimize table proxyaccess;"
    }

    function create_proxydenied () {
    if [ -z $($SQLCMD -ss -e "SHOW tables like 'proxydenied$TBLEXT'") ]; then
    echo creation de la table proxydenied$TBLEXT
    $SQLCMD -e "CREATE TABLE proxydenied$TBLEXT (date datetime NOT NULL,proxy char(6) NOT NULL,user char(25) NOT NULL,IP char(15) NOT NULL,fqdn char(64) NOT NULL,url text NOT NULL,http_status int(11) NOT NULL,squid_status char(25) NOT NULL,method char(8) NOT NULL,reqtime int(11) NOT NULL,taille int(11) NOT NULL) ENGINE=ARCHIVE DEFAULT CHARSET=latin1"
    fi
    }

    function archive_proxydenied () {
    echo archivage des logs du proxy \(proxydenied$TBLEXT\)
    create_proxydenied
    $SQLCMD -e "insert into proxydenied$TBLEXT select * from proxydenied where date < date_format(now(),'%Y-%m-%d');delete from proxydenied where date < date_format(now(),'%Y-%m-%d');optimize table proxydenied;"
    }

    function archive () {
    archive_proxyaccess
    archive_proxydenied
    }

    #############################################
    #########Functions de statistiques
    #############################################

    function set_mode () {
    if [ 'date +%d' = "01" ]; then
    STATMOIS="1"
    else
    STATMOIS="0"
    fi

    if [ 'date +%w' = "1" ]; then
    STATSEM="1"
    else
    STATSEM="0"
    fi
    }

    function stats() {
    set_mode
    stat_mois
    stat_semaine
    stat_jour
    }
    ###########################################
    ##########Programme principal
    ###########################################
    archive
    voici l'erreur
    archivage des logs du proxy (proxyaccessdate --date=yesterday +%Y%m)
    creation de la table proxydenieddate --date=yesterday +%Y%m
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m (date datetime NOT NULL,proxy char(6) NOT NULL,user char(' at line 1
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m select * from proxyaccess where date < date_format(now(),' at line 1
    archivage des logs du proxy (proxydenieddate --date=yesterday +%Y%m)
    creation de la table proxydenieddate --date=yesterday +%Y%m
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m (date datetime NOT NULL,proxy char(6) NOT NULL,user char(' at line 1
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m select * from proxydenied where date < date_format(now(),' at line 1
    voici le 2e script

    #!/bin/sh

    SQLUSER="xxxx"
    SQLPASS="yyyy"
    SQLBASE="httpd"
    SQLCMD="mysql -u$SQLUSER -p$SQLPASS $SQLBASE"

    TBLEXT='date --date=yesterday +%Y%m'


    #########################################
    #########Fonctions d'archivage
    #########################################

    function create_httpaccess () {
    if [ -z $($SQLCMD -ss -e "SHOW tables like 'httpaccess$TBLEXT'") ]; then
    echo creation de la table httpdaccess$TBLEXT
    $SQLCMD -e "CREATE TABLE httpaccess$TBLEXT (date datetime NOT NULL,srv char(10) NOT NULL,vhost char(64) NOT NULL,user char(25) NOT NULL,IP char(15) NOT NULL,fqdn char(64) NOT NULL,url text NOT NULL,http_status int(11) NOT NULL,method char(8) NOT NULL,taille int(11) NOT NULL,user_agent text NOT NULL) ENGINE=ARCHIVE DEFAULT CHARSET=latin1"
    fi
    }

    function archive_httpaccess () {
    echo archivage des logs de httpd \(httpaccess$TBLEXT\)
    create_httpaccess
    echo deplacement des donnees vers httpaccess$TBLEXT
    $SQLCMD -e "insert into httpaccess$TBLEXT select * from httpaccess where date < date_format(now(),'%Y-%m-%d');delete from httpaccess where date < date_format(now(),'%Y-%m-%d');optimize table httpaccess;"
    }
    function archive () {
    archive_httpaccess
    }
    ########################################
    #########Programme principal
    ########################################
    archive
    Voici l'erreur

    archivage des logs de httpd (httpaccessdate --date=yesterday +%Y%m)
    creation de la table httpdaccessdate --date=yesterday +%Y%m
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m (date datetime NOT NULL,srv char(10) NOT NULL,vhost char(' at line 1
    deplacement des donnees vers httpaccessdate --date=yesterday +%Y%m
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m select * from httpaccess where date < date_format(now(),'' at line 1
    qlq'1 peut-il m'aider svp. c vraiment urgent.
    Merci.

  2. #2
    Membre éprouvé
    Avatar de Sivrît
    Profil pro
    Inscrit en
    Février 2006
    Messages
    953
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Février 2006
    Messages : 953
    Points : 1 249
    Points
    1 249
    Par défaut
    Citation Envoyé par cratos1 Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TBLEXT="date --date=yesterday +%Y%m"
    A première vue, il faudrait des backquote (`).

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 5
    Points : 4
    Points
    4
    Par défaut
    effectivement c'était un probleme de backquot.
    Après correction, test ok.

    Merci Sivrît

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. PHP vers MYSQL probleme de syntaxe
    Par armand6464 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 01/09/2014, 11h07
  2. [MySQL] probleme syntaxe mysql implode et tableau
    Par lol88 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 18/04/2010, 11h40
  3. Probleme syntaxe mysql
    Par Loenix dans le forum Bibliothèques tierces
    Réponses: 1
    Dernier message: 26/11/2008, 12h44
  4. probleme syntaxe mysql
    Par jsdar dans le forum Requêtes
    Réponses: 3
    Dernier message: 04/04/2007, 01h01
  5. Problemes de syntaxe
    Par maahta dans le forum SQL Procédural
    Réponses: 3
    Dernier message: 01/10/2003, 13h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo