Home > English - 英文 > Install MySQL from source in a Linux box

Install MySQL from source in a Linux box

February 20th, 2010 Bali Leave a comment Go to comments

I had a CentOS Linux box bundled with a MySQL with Latin as default charset. As time goes by, I need

a) utf-8 everywhere(client, server, collation, everywhere) to support Chinese.

b) Innodb as default engine

Here is what I did:

1) Download latest source(mysql-5.1.44) from MySQL site

2) rpm -i xxx.src.rpm to install the source. By default, the source will be installed to /usr/src/redhat/SOURCES/mysql-5.1.44.

3) Go the root dir of source, run:

CFLAGS=”-O3″ CXX=gcc CXXFLAGS=”-O3 -felide-constructors \
-fno-exceptions -fno-rtti” ./configure \
–prefix=/usr/local/mysql –enable-assembler \
–with-mysqld-ldflags=-all-static \
–with-charset=utf8 \
–with-collation=utf8_general_ci \
–with-plugins=all

Explain: use gcc as compiler; install mysql to /usr/local/mysql; utf8 as default char set; install all plugins including innodb.

During this process, you may see errors saying “I need this, I need that”, use ‘yum‘ to install them.

And ./configure –help will show all possible options.

4) make

5) make install

And /usr/local/mysql will be the rool dir of new mysql installation.

6) Modify /etc/my.cnf. /usr/src/redhat/SOURCES/mysql-5.1.44/support-files/ contains sample configuration files. Note to set below:

[mysqld]

default-storage-engine = INNODB

7) Modify /etc/init.d/mysqld. You may need sym-link to new mysql installation.

Done. Below message should prove the installation is fine:

mysql> show engines;
+————+———+—————————————————————-+————–+——+————+
| Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints |
+————+———+—————————————————————-+————–+——+————+
| ndbcluster | NO      | Clustered, fault-tolerant tables                               | NULL         | NULL | NULL       |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB     | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MyISAM     | YES     | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
+————+———+—————————————————————-+————–+——+————+
9 rows in set (0.00 sec)

mysql> show variables like ‘%char%’;
+————————–+—————————————-+
| Variable_name            | Value                                  |
+————————–+—————————————-+
| character_set_client     | utf8                                   |
| character_set_connection | utf8                                   |
| character_set_database   | utf8                                   |
| character_set_filesystem | binary                                 |
| character_set_results    | utf8                                   |
| character_set_server     | utf8                                   |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
+————————–+—————————————-+
8 rows in set (0.00 sec)

mysql> show variables like ‘%colla%’;
+———————-+—————–+
| Variable_name        | Value           |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+———————-+—————–+
3 rows in set (0.00 sec)

Categories: English - 英文 Tags: ,
  1. Foam
    February 21st, 2010 at 14:10 | #1

    收藏!

  1. No trackbacks yet.