知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

Linux下安装MySQL

发布时间:2014-09-05 16:39:10作者:知识屋

 

MySQL-5.0.41

 

Introduction to MySQL

MySQL is a widely used and fast SQL database server. It is a client/server implementation that consists of a server daemon and many different client programs and libraries.

There may be a more recent release available from the MySQL home page. You can check http://dev.mysql.com/ and probably use the existing BLFS instructions. Note that versions other than the one shown in the download URLs have not been tested in a BLFS environment.

Package Information

Download (HTTP): http://anduin.linuxfromscratch.org/sources/BLFS/6.3/m/mysql-5.0.41.tar.gz

Download (FTP): ftp://anduin.linuxfromscratch.org/BLFS/6.3/m/mysql-5.0.41.tar.gz

Download MD5 sum: b45cd6c89e35dfc1cdbe1a1f782aefbf

Download size: 24 MB

Estimated disk space required: 405 MB (additional 65 MB to run the test suite)

Estimated build time: 6.0 SBU (Test suite is an additional 52 minutes, only partially CPU dependent)

MySQL Dependencies

Optional

OpenSSL-0.9.8g and TCP Wrapper-7.6

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/mysql

Installation of MySQL

For security reasons, running the server as an unprivileged user and group is strongly encouraged:

groupadd -g 40 mysql && useradd -c "MySQL Server" -d /dev/null -g mysql -s /bin/false / -u 40 mysql

Build and install MySQL by running the following commands:

C_EXTRA_FLAGS=-fno-strict-aliasing / ./configure --prefix=/usr / --sysconfdir=/etc / --libexecdir=/usr/sbin / --localstatedir=/srv/mysql / --enable-thread-safe-client / --enable-assembler / --enable-local-infile / --with-unix-socket-path=/var/run/mysql/mysql.sock / --without-debug / --without-bench / --without-readline / --with-berkeley-db / --with-extra-charsets=all && make testdir=/tmp/mysql

To test the results, issue: make test. Note that if you have a restrictive /etc/hosts.deny file, you will need to add an appropriate entry to the /etc/hosts.allow file for the mysqld daemon, else many of the tests will fail.

Now, as the root user:

make testdir=/tmp/mysql install && rm -rf /tmp/mysql && cd /usr/lib && ln -v -sf mysql/libmysqlclient{,_r}.so* .

  Tip

The only documentation shipped in the source tarball are mysql.info and manual.chm (Microsoft Help format) files. You can download various formats of the MySQL Reference Manual from http://dev.mysql.com/doc/.

Command Explanations

C_EXTRA_FLAGS=-fno-strict-aliasing: This environment variable adjusts the compiler optimization to avoid failures in the testsuite and other operations.

--libexecdir=/usr/sbin: This switch installs the mysqld daemon and the mysqlmanager program in an appropriate location.

--localstatedir=/srv/mysql: This switch forces MySQL to use /srv/mysql for database files and other variable data.

--enable-thread-safe-client: This switch compiles a thread-safe MySQL client library.

--enable-assembler: This switch allows using assembler versions of some string functions.

--enable-local-infile: This switch enables the “LOAD DATA INFILE” SQL statement.

--with-unix-socket-path=/var/run/mysql: This switch puts the unix-domain socket into the /var/run/mysql directory instead of the default /tmp.

--without-bench: This switch skips building the benchmark suite.

--without-readline: This switch forces the build to use the system copy of readline instead of the bundled copy.

--with-berkeley-db: This switch enables using Berkeley DB tables as a back end.

--with-extra-charsets=all: This switch enables international character sets within the suite.

make testdir=...: This installs the test suite in /tmp/mysql. The test suite is not required, nor does it function properly on an installed version of MySQL, so it is removed in the next step.

ln -v -sf mysql/libmysqlclient{,_r}.so* .: This command makes the MySQL shared libraries available to other packages at run-time.

--with-openssl: This switch adds OpenSSL support to MySQL.

--with-libwrap: This switch adds tcpwrappers support to MySQL.

Configuring MySQL

Config Files

/etc/my.cnf and ~/.my.cnf

Configuration Information

There are several default configuration files available in /usr/share/mysql which you can use. Create /etc/my.cnf using the following command as the root user:

install -v -m644 /usr/share/mysql/my-medium.cnf /etc/my.cnf

You can now install a database and change the ownership to the unprivileged user and group (perform as the root user):

mysql_install_db --user=mysql && chgrp -v mysql /srv/mysql{,/test,/mysql}

Further configuration requires that the MySQL server is running. Start the server using the following commands as the root user:

install -v -m755 -o mysql -g mysql -d /var/run/mysql && mysqld_safe --user=mysql 2>&1 >/dev/null &

A default installation does not set up a password for the administrator, so use the following command as the root user to set one. Replace <new-password> with your own.

mysqladmin -u root password <new-password>

Configuration of the server is now finished. Shut the server down using the following command as the root user:

mysqladmin -p shutdown

Boot Script

Install the /etc/rc.d/init.d/mysql init script included in the blfs-bootscripts-20080816 package as the root user to start the MySQL server during system boot-up.

make install-mysql

Contents

Installed Programs:

comp_err, innochecksum, msql2mysql, my_print_defaults, myisam_ftdump, myisamchk, myisamlog, myisampack, mysql, mysql_client_test, mysql_config, mysql_convert_table_format, mysql_create_system_tables, mysql_explain_log, mysql_find_rows, mysql_fix_extensions, mysql_fix_privilege_tables, mysql_install_db, mysql_secure_installation, mysql_setpermission, mysql_tableinfo, mysql_tzinfo_to_sql, mysql_waitpid, mysql_zap, mysqlaccess, mysqladmin, mysqlbinlog, mysqlbug, mysqlcheck, mysqld, mysqld_multi, mysqld_safe, mysqldump, mysqldumpslow, mysqlhotcopy, mysqlimport, mysqlmanager, mysqlshow, mysqltest, mysqltestmanager, mysqltestmanager-pwgen, mysqltestmanagerc, perror, replace, resolve_stack_dump, and resolveip

Installed Libraries:

libdbug.a, libheap.a, libmyisam.a, libmyisammrg.a, libmysqlclient.{so,a}, libmysqlclient_r.{so,a}, libmystrings.a, libmysys.a, and libvio.a

Installed Directories:

/srv/mysql, /usr/include/mysql, /usr/lib/mysql, /usr/share/mysql, and /var/run/mysql

Short Descriptions

Descriptions of all the programs and libraries would be several pages long. Instead, consult the mysql.info documentation or the on-line reference manual at http://dev.mysql.com/doc/refman/5.0/en/index.html.

The Perl DBI modules must be installed for some of the MySQL support programs to function properly.

Last updated on 2008-05-10 18:53:20 -0500

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜