hn4u @ Last updated 21/11/04 22:42
Go to my homepage at http://4u.jcisio.com
Full version available at http://4u.jcisio.com/r/article228.htm

Hải Nam

Cài đặt mySQL

Cài đặt cơ bản

Cài mySQL trong Linux

The recommended way to install MySQL on Linux is by using an RPM file. The MySQL RPMs are currently being built on a RedHat Version 6.2 system but should work on other versions of Linux that support rpm and use glibc.

If you have problems with an RPM file, for example, if you receive the error ``Sorry, the host 'xxxx' could not be looked up'', see section 2.6.1.1 Linux Notes for Binary Distributions.

The RPM files you may want to use are:

MySQL-VERSION.i386.rpm The MySQL server. You will need this unless you only want to connect to a MySQL server running on another machine.

MySQL-client-VERSION.i386.rpm The standard MySQL client programs. You probably always want to install this package.

MySQL-bench-VERSION.i386.rpm Tests and benchmarks. Requires Perl and msql-mysql-modules RPMs.

MySQL-devel-VERSION.i386.rpm Libraries and include files needed if you want to compile other MySQL clients, such as the Perl modules.

MySQL-VERSION.src.rpm This contains the source code for all of the above packages. It can also be used to try to build RPMs for other architectures (for example, Alpha or SPARC).

To see all files in an RPM package, run:

shell> rpm -qpl MySQL-VERSION.i386.rpm

To perform a standard minimal installation, run:

shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm

To install just the client package, run:

shell> rpm -i MySQL-client-VERSION.i386.rpm

The RPM places data in `/var/lib/mysql'. The RPM also creates the appropriate entries in `/etc/rc.d/' to start the server automatically at boot time. (This means that if you have performed a previous installation, you may want to make a copy of your previously installed MySQL startup file if you made any changes to it, so you don't lose your changes.)

After installing the RPM file(s), the mysqld daemon should be running and you should now be able to start using MySQL. See section 2.4 Post-installation Setup and Testing.

If something goes wrong, you can find more information in the binary installation chapter. See section M.1 Installing a MySQL Binary Distribution.

Cài đặt mySQL trong Windows

Các chỉ dẫn dưới đây dành cho các phiên bản đã được dịch. Nếu bạn download mã nguồn, bạn phải tự dịch và cài đặt nó.

Nếu chưa có bản cài đặt, bạn hãy download ở đây.

If you plan to connect to MySQL from some other program, you will probably also need the MyODBC driver. You can find this at the MyODBC download page (http://www.mysql.com/downloads/api-myodbc.html).

To install either distribution, unzip it in some empty directory and run the Setup.exe program.

By default, MySQL-Windows is configured to be installed in `C:\mysql'. If you want to install MySQL elsewhere, install it in `C:\mysql' first, then move the installation to where you want it. If you do move MySQL, you must indicate where everything is located by supplying a --basedir option when you start the server. For example, if you have moved the MySQL distribution to `D:\programs\mysql', you must start mysqld like this:

C:\> D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql

Use mysqld --help to display all the options that mysqld understands!

With all newer MySQL versions, you can also create a `C:\my.cnf' file that holds any default options for the MySQL server. Copy the file `\mysql\my-xxxxx.cnf' to `C:\my.cnf' and edit it to suit your setup. Note that you should specify all paths with `/' instead of `\'. If you use `\', you need to specify it twice, because `\' is the escape character in MySQL. See section 4.1.2 my.cnf Option Files.

Starting with MySQL 3.23.38, the Windows distribution includes both the normal and the MySQL-Max binaries. The main benefit of using the normal mysqld.exe binary is that it's a little faster and uses less resources.

Here is a list of the different MySQL servers you can use:

mysqld  Compiled with full debugging and automatic memory allocation checking, symbolic links, BDB and InnoDB tables.

mysqld-opt  Optimized binary with no support for transactional tables.

mysqld-nt  Optimized binary for NT with support for named pipes. You can run this version on Win98, but in this case no named pipes are created and you must have TCP/IP installed.

mysqld-max  Optimized binary with support for symbolic links, BDB and InnoDB tables.

mysqld-max-nt  Like mysqld-max, but compiled with support for named pipes.

All of the above binaries are optimized for the Pentium Pro processor but should work on any Intel processor >= i386.

NOTE: If you want to use InnoDB tables, there are certain startup options that must be specified in your `my.ini' file! See section 7.6.2 InnoDB startup options.


hainam4u @ Last updated 21/11/04 22:42
Go to my homepage at http://4u.jcisio.com