Eric
Le premier départ avec mySQL
[root@pdsec]:/usr/sfw/share/mysql# mysql_install_db Preparing db table Preparing host table Preparing user table Preparing func table Preparing tables_priv table Preparing columns_priv table Installing all prepared tables 051011 14:47:55 /usr/sfw/sbin/mysqld: Shutdown Complete To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! This is done with: /usr/sfw/bin/mysqladmin -u root password 'new-password' /usr/sfw/bin/mysqladmin -u root -h pdsec password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: /usr/sfw/bin/mysqld_safe & You can test the MySQL daemon with the tests in the 'mysql-test' directory: cd /usr/sfw/mysql/mysql-test; ./mysql-test-run Please report any problems with the /usr/sfw/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at https://order.mysql.com
Posted at 03:00PM oct. 11, 2005 by Éric in mysql |
Activer la réplication sous mySQL entre les serveurs
Tested on MySQL versions 4.0.20 1. Edit the my.cnf file on the slave and on the master server: -master my.cnf: [mysqld] server-id = 1 log-bin -slave my.cnf: [mysqld] server-id = 2 #replicate-do-db = database1 # for Replicating specific databases 2. Restart both the slave and the master. 3. SQL SYNTAX: --On the master do mysql> GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO repl IDENTIFIED BY 'password'; some time you need to use GRANT ALL ON *.* TO repl IDENTIFIED BY 'password'; mysql> FLUSH PRIVILEGES; mysql> FLUSH TABLES WITH READ LOCK; mysql> SHOW MASTER STATUS; --On the SLAVE do mysql> CHANGE MASTER to MASTER_HOST='master.host.,MASTER_PORT=3306, MASTER_USER='repl',MASTER_PASSWORD='password',MASTER_LOG_FILE='',MASTER_LOG_POS=4; mysql> STOP SLAVE; #--If already started mysql> START SLAVE; 4. On the slave do: mysql> LOAD DATA FROM MASTER; The slave should now download the databases specified with replicate-do-db in the slaves my.cnf, and be replicating new data. NOTE: Please sure that the MASTER_USER had required privilege .
Posted at 12:00AM avr. 03, 2005 by Éric in mysql |
Ajouter mySQL au service SMF sous solaris 10
Converting MySQL into a Service
Remove Legacy Start-Up Process
The integrated MySQL (RDBMS) Solaris package provides a maintenance
script for starting, stopping and restarting. This script is located
in /etc/sfw/mysql and is called mysql.server. The
default Solaris 10 installation doesn't reference this script during
the traditional start-up process. The system administrator may have
copied (or linked) this script into the traditional start-up
directories. You will need to remove any MySQL start-up scripts in
/etc/rc*.d and /etc/init.d.
Use the following commands to check for any existing mysql start-up
scripts:
# find /etc/rc* /etc/init.d | grep -i mysql /etc/rc0.d/K01mysql /etc/rc1.d/K01mysql /etc/rc2.d/K01mysql /etc/rc3.d/S99mysql /etc/init.d/mysql
If the above command finds start-up scripts (as shown above), they need
to be removed or relocated. Remove the scripts from the /etc/rc*
directories:
# rm /etc/rc0.d/K01mysql # rm /etc/rc1.d/K01mysql # rm /etc/rc2.d/K01mysql # rm /etc/rc3.d/S99mysql
Relocate the script in /etc/init.d to an alternate location:
# mv /etc/init.d/mysql /var/tmp
Create SMF mysql Manifest
SMF in the Solaris 10 OS has established a directory structure for storing SMF
service manifests. The base directory for SMF manifests is
/var/svc/manifest. For organizational purposes, as root, create a new directory called database under the application directory. Create a text file called mysql.xml
and insert the XML manifest that defines the MySQL service (see
below). The mysql manifest XML file needs to be
copied into this directory.
# mkdir /var/svc/manifest/application/database # vi mysql.xml (insert the manifest below) # cp mysql.xml /var/svc/manifest/application/database
The complete manifest for the mysql service is listed
in the following example.
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
MySQL.xml : MySQL manifest, Scott Fehrman, Systems Engineer
updated: 2005-09-16
-->
<service_bundle type='manifest' name='MySQL'>
<service name='application/database/mysql' type='service' version='1'>
<single_instance />
<dependency
name='filesystem'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/system/filesystem/local' />
</dependency>
<exec_method
type='method'
name='start'
exec='/etc/sfw/mysql/mysql.server start'
timeout_seconds='120' />
<exec_method
type='method'
name='stop'
exec='/etc/sfw/mysql/mysql.server stop'
timeout_seconds='120' />
<instance name='default' enabled='false' />
<stability value='Unstable' />
<template>
<common_name>
<loctext xml:lang='C'>MySQL RDBMS 4.0.15</loctext>
</common_name>
<documentation>
<manpage title='mysql' section='1' manpath='/usr/sfw/share/man' />
</documentation>
</template>
</service>
</service_bundle>
Import the Manifest into the Repository
Placing the XML file into the SMF directory does not mean the mysql service is ready for use.
The manifest needs to be validated and imported into the Solaris 10 SMF Repository. Validate and import the
XML file into the Repository with the svccfg (Service Configuration) command:
# svccfg validate /var/svc/manifest/application/database/mysql.xml # svccfg import /var/svc/manifest/application/database/mysql.xml
Check the Service
The service will automatically start when the Solaris 10 OS boots if the service
is enabled. The XML file contains the line <instance
name='default' enabled='false' />, which means the
service will not be enabled when it's imported into the Repository.
Check the status of the service with the svcs
command:
Status of the service:
# svcs mysql STATE STIME FMRI disabled 12:45:34 svc:/application/database/mysql:default
Posted at 12:00AM mars 31, 2005 by Éric in mysql |
Commande de base sous mySQL
Pour creer une BD
1) #mysql
2) mysql> create database exemplebd;
Pour supprimer une BD
1) #mysql
2) mysql> drop database exemplebd;
Pour creer les tables dans une BD avec un script
1) # mysql exemplebd < cr_dumpbd.sql
Pour saugarder une BD
1) #mysqldump --opt exempledb > cr_dumpbd.sql
Pour afficher le contenu d'une table
1) #mysql
2) mysql> select * table;
delete user
DELETE FROM mysql.user WHERE User='username';
Cree un usager qui a tout les droits sur une bd
GRANT ALL PRIVILEGES ON database.table TO username@localhost IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
Posted at 12:00AM août 19, 2002 by Éric in mysql |
Liste des champs sous mySQL
* TINYINT : Entier de 0 à 255 (unsigned)
* SMALLINT : Entier de 0 à 65535 (unsigned)
* MEDIUMINT : Entier de 0 à 16777215 (unsigned)
* INT : Entier de 0 à 4294967295 (unsigned)
* BIGINT : Entier de 0 à 18446744073709551615 (unsigned)
* DECIMAL : Un nombre à virgule flottante
* DATE : Une date, va de '1000-01-01' à '9999-12-31'
* DATETIME : Date et Heure, va de '1000-01-01 00:00:00' à '9999-12-31 23:59:59'
* TIMESTAMP : Date et Heure exprimée en secondes depuis le 1er janviers 1970. Va de '1970-01-01 00:00:00' à quelque part, durant l'année 2037
* TIME : Une mesure de l'heure, va de '-838:59:59' à '838:59:59'
* YEAR : Une annnée, va de 1901 à 2155
* CHAR : Chaîne de caractère de taille fixe, va de 1 à 255 caractères
* VARCHAR : Chaîne de caractère de taille variable, va de 1 à 255 caractères
* TINYTEXT ou TINYBLOB : Un objet BLOB ou TEXT, longueur maximale de 255
* TEXT ou BLOB : Un objet BLOB ou TEXT, longueur maximale de 65535
* MEDIUMTEXT ou MEDIUMBLOB : Un objet BLOB ou TEXT, longueur maximale de 16777215
* LONGTEXT ou LONGBLOB : Un objet BLOB ou TEXT, longueur maximale de 4294967295
Posted at 12:00AM mars 29, 2002 by Éric in mysql |





