Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Saturday, July 14, 2007

Character Sets and Collations in MySQL

A character set is a set of symbols and encodings. A collation is a set of rules for comparing characters in a character set.

The MySQL server can support multiple character sets. To list the available character sets, use the SHOW CHARACTER SET statement.
mysql> SHOW CHARACTER SET;
Any given character set always has at least one collation. It may have several collations. To list the collations for a character set, use the SHOW COLLATION statement.
mysql> SHOW COLLATION LIKE 'latin1%';

Every database has a database character set and a database collation. The CREATE DATABASE and ALTER DATABASE statements have optional clauses for specifying the database character set and collation:
CREATE DATABASE db_name
[[DEFAULT] CHARACTER SET charset_name]
[[DEFAULT] COLLATE collation_name]


ALTER DATABASE db_name
[[DEFAULT] CHARACTER SET charset_name]
[[DEFAULT] COLLATE collation_name]


Example:
CREATE DATABASE db_name CHARACTER SET latin1 COLLATE latin1_swedish_ci;

The database character set and collation are used as default values if the table character set and collation are not specified in CREATE TABLE statements. They have no other purpose.

In order to check teh character set and collation for the databases, tables and columns, you can go to the information_schema database, and check the table called SCHEMATA.
mysql> SELECT * FROM SCHEMATA;

Installing and testing MySQL Server 5.0.45

Instructions for installations are available in Install MySQL on a RH machine .
Basic commands include:

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz tar xvf -

shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &


If mysqld is currently running, you can find out what path settings it is using by executing this command:
shell> mysqladmin variables
Or:
shell> mysqladmin -h host_name variables

Another good instruction on installing MySQL Server is available here.

Tuesday, March 13, 2007

how to back up mysql database for a website?

Just got a good article about how to back up MySQL database using phpMyAdmin, which is very useful when maintaining a website.
Please click " Backup and Importing Joomla Database " (from GeekTips.net) to get the detailed information.

Wednesday, January 31, 2007

Configure MySQL with PHP

Product version: PHP5 (Non-installed version for windows), MySQL5 (Non-installed version for windows).
Steps:
(1) Use php.ini-recommended as the default ini file by renaming it to php.ini.
(2) In the development environment, it's useful to set display_errors = on. When moving the web application to production, this switch should be turned off.
(3) Check the document root in the following line: doc_root ="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" .
(4) Specify the loadable module directory extension_dir = "C:\php5\ext" .
(5) Enable php_mysql.dll inside of php.ini by removing semicolon from the line ;extension=php_mysql.dll .
(6) PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. So add "C:\php5\" to PATH environmental variable.
(7) Specify upload_tmp_dir and session.save_path if necessary.
(8) Copy some extension pointers in the orginal php.ini file into the new php.ini file.