Create MySQL's users on OSX

Proper database can be created with the MySQL monitor, like that:

CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

To check character set settings for your database, issue command:

mysql> USE trac;
Database changed
mysql> SHOW VARIABLES LIKE '%character%';
+--------------------------+--------------------
| Variable_name            | Value
+--------------------------+--------------------
| character_set_client     | cp1251
| character_set_connection | cp1251
| character_set_database   | utf8
| character_set_filesystem | binary
| character_set_results    | cp1251
| character_set_server     | utf8
| character_set_system     | utf8
| character_sets_dir       | C:\DevServer\Instal
+--------------------------+--------------------
8 rows in set (0.00 sec)
mysql>
See also #3884.

Usually, you also want to create a user and give this user access to the database created above:

CREATE USER tracuser IDENTIFIED BY 'password';
GRANT ALL ON trac.* TO tracuser;

The connection string will then be:

mysql://tracuser:password@localhost/trac

Troubleshooting

If you get an error from python when using trac-admin like this:

OperationalError: (1045, "Access denied for user 'tracuser'@'localhost' (using password: YES)")

There are a few possibilities:

  1. Try first to login on the command-line using the user tracuser (mysql -p -h localhost -u tracuser)
  2. Created user is not yet used by MySQL (Login to the MySQL server(as root): mysql -p and type FLUSH PRIVILEGES;)
  3. The user is added but the host does not match in the mysql user table (I had this on my FreeBSD setup). mysql -p; use mysql; UPDATE user SET Host="localhost" WHERE User="tracuser"; FLUSH PRIVILEGES;)

Installer Sphinx sur OSX

Marqué :

Ce tuto utilise wget, qui n'est pas installé sur Leopard. Pour l'installer, la procédure est disponible ici.

# Download sphinx
wget http://sphinxsearch.com/downloads/sphinx-0.9.9-rc2.tar.gz
tar zxvf sphinx-0.9.9-rc2.tar.gz

cd sphinx-0.9.9-rc2/

# Add stemming support
wget http://snowball.tartarus.org/dist/libstemmer_c.tgz
tar zxvf libstemmer_c.tgz

./configure --with-libstemmer
make

sudo make install

Installer LXML sur mac OS X 10.5

Marqué :

assuming your python is the mac os x default… make sure no traces of other pythons in your $PATH

télécharger et installer libxml2:

./configure --prefix=/usr/local/libxml2-2.7.0
make
sudo make install
cd /Library/Python/2.5/site-packages
sudo ln -s /usr/local/libxml2-2.7.0/lib/python2.5/site-packages/* .

télécharger et installer libxslt:

./configure --prefix=/usr/local/libxslt-1.1.24 --with-libxml-prefix=/usr/local/libxml2-2.7.0
make
sudo make install
cd /Library/Python/2.5/site-packages
sudo ln -s /usr/local/libxslt-1.1.24/lib/python2.5/site-packages/* .

télécharger et installer lxml:

sudo python setup.py install \
--with-xml2-config=/usr/local/libxml2-2.7.0/bin/xml2-config \
--with-xslt-config=/usr/local/libxslt-1.1.24/bin/xslt-config

Installer MySQL Proxy sur Mac OSX (Leopard)

Les prérequis

Installer pkg-config

Télécharger l'archive http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz, puis la décompresser

cd pkg-config-0.23
./configure
make
sudo make install

Installer lua

Télécharger l'archive http://www.lua.org/ftp/lua-5.1.4.tar.gz, puis la décompresser

cd lua-5.1.4/
make macosx
sudo make install
sudo cp etc/lua.pc /usr/local/lib/pkgconfig/
sudo ranlib /usr/local/lib/liblua.a

Installer glib2

Prérequis

Cette librairie dépend de Gettext. L'installer si ce n'est pas déjà fait http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz

Télécharger http://www.icewalkers.com/download/GLib2/1598-2458/old/

Faceted search with Sphinx and PHP

Marqué :
<?php
/*
 * Faceted implementation in Sphinx
 * 
 * the 10 best match will be stored into 
 * $result_list = array()
 * 
 * the 100 values fore each filters will be stored into
 * $bundle_filters_results = array()
 */

// search exemple
$query_search = "your query";
$attrs_search = array("one"=>10, "three"=>2);

// parameters
$config_index = "your_index";
$config_filters = array('one', 'two', 'three');

//
// 1. get the 10 best matchs documents
//

// Prepare the query
$sphinx_instance->SetLimits( 0, 10, 10 );
$sphinx_instance->SetRankingMode( SPH_RANK_PROXIMITY_BM25 );

foreach($attrs_search as $key => $value) {
    $sphinx_instance->SetFilter($key, $value);
}

// Fetch the results
$result_list = $sphinx_instance->Query($query, $config_index);

//
// 2. get 100 values for each filters tied to the current search
//

// Prepare the queries
$sphinx_instance->SetLimits( 0, 100, 100 );
$sphinx_instance->SetRankingMode ( SPH_RANK_NONE );

for($i=0; $i<count($config_filters); $i++) {
    $current_filter = $config_filters[$i];

    $sphinx_instance->ResetFilters();
    $sphinx_instance->ResetGroupBy();
    $sphinx_instance->ResetQueryString();

    // query every others filters
    foreach($attrs_search as $key => $value) {
        if( $key != $current_filter) {
            $sphinx_instance->SetFilter( $key, $value );
        }

    }
    $sphinx_instance->SetGroupBy($current_filter, SPH_GROUPBY_ATTR, "@count desc");
    $sphinx_instance->AddQuery( $query_search, $config_index );
}

// Fetch all results
$sphinx_instance->SetArrayResult(true);
$tmp_filters_results = $sphinx_instance->RunQueries();

$bundle_filters_results = array();
for($i=0; $i<count($config_filters); $i++) {
    $current_filter = $config_filters[$i];

    $bundle_filters_results[$current_filter] = $tmp_filters_results[0];
}
?>