文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>linux下mysql4.0安装

linux下mysql4.0安装

时间:2006-09-16  来源:purple_lotuses

下载地址为 http://dev.mysql.com/downloads/mysql/5.0.html 我下载的是源码包,下面是mysql官方网站的安装文档,地址为http://dev.mysql.com/doc/reman/4.1/en/installing-binary.html,其第二章为安装文档。之前试过装rpm的包,但一直没成功,

2.9.1. Source Installation Overview

The basic commands that you must execute to install a MySQL source distribution are:

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql

shell> make

shell> make install

shell> cp support-files/my-medium.cnf /etc/my.cnf

shell> cd /usr/local/mysql

shell> bin/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

If you start from a source RPM, do the following:

shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

This makes a binary RPM that you can install. For older versions of RPM, you may have to replace the command rpmbuild with rpm instead.

Note: This procedure does not set up any passwords for MySQL accounts. After following the procedure, proceed to Section 2.10, “Post-Installation Setup and Testing”, for post-installation setup and testing.

A more detailed version of the preceding description for installing MySQL from a source distribution follows:

  1. Add a login user and group for mysqld to run as:

2.           shell> groupadd mysql

3.           shell> useradd -g mysql mysql

These commands add the mysql group and the mysql user. The syntax for useradd and groupadd may differ slightly on different versions of Unix, or they may have different names such as adduser and addgroup.

You might want to call the user and group something else instead of mysql. If so, substitute the appropriate name in the following steps.

  1. Pick the directory under which you want to unpack the distribution and change location into it.
  2. Obtain a distribution file using the instructions in Section 2.1.3, “How to Get MySQL”.
  3. Unpack the distribution into the current directory:

7.           shell> gunzip < /path/to/mysql-VERSION.tar.gz | tar xvf -

This command creates a directory named mysql-VERSION.

With GNU tar, no separate invocation of gunzip is necessary. You can use the following alternative command to uncompress and extract the distribution:

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

  1. Change location into the top-level directory of the unpacked distribution:

9.           shell> cd mysql-VERSION

Note that currently you must configure and build MySQL from this top-level directory. You cannot build it in a different directory.

  1. Configure the release and compile everything:

11.       shell> ./configure --prefix=/usr/local/mysql

12.       shell> make

When you run configure, you might want to specify other options. Run ./configure --help for a list of options. Section 2.9.2, “Typical configure Options”, discusses some of the more useful options.

If configure fails and you are going to send mail to a MySQL mailing list to ask for assistance, please include any lines from config.log that you think can help solve the problem. Also include the last couple of lines of output from configure. To file a bug report, please use the instructions in Section 1.8, “How to Report Bugs or Problems”.

If the compile fails, see Section 2.9.4, “Dealing with Problems Compiling MySQL”, for help.

  1. Install the distribution:

14.       shell> make install

If you want to set up an option file, use one of those present in the support-files directory as a template. For example:

shell> cp support-files/my-medium.cnf /etc/my.cnf

You might need to run these commands as root.

If you want to configure support for InnoDB tables, you should edit the /etc/my.cnf file, remove the # character before the option lines that start with innodb_..., and modify the option values to be what you want. See Section 4.3.2, “Using Option Files”, and Section 14.5.3, “InnoDB Configuration”.

  1. Change location into the installation directory:

16.       shell> cd /usr/local/mysql

  1. If you haven't installed MySQL before, you must create the MySQL grant tables:

18.       shell> bin/mysql_install_db --user=mysql

If you run the command as root, you should use the --user option as shown. The value of the option should be the name of the login account that you created in the first step to use for running the server. If you run the command while logged in as that user, you can omit the --user option.

After using mysql_install_db to create the grant tables for MySQL, you must restart the server manually. The mysqld_safe command to do this is shown in a later step.

  1. Change the ownership of program binaries to root and ownership of the data directory to the user that you run mysqld as. Assuming that you are located in the installation directory (/usr/local/mysql), the commands look like this:

20.       shell> chown -R root  .

21.       shell> chown -R mysql var

22.       shell> chgrp -R mysql .

The first command changes the owner attribute of the files to the root user. The second changes the owner attribute of the data directory to the mysql user. The third changes the group attribute to the mysql group.

  1. If you want MySQL to start automatically when you boot your machine, you can copy support-files/mysql.server to the location where your system has its startup files. More information can be found in the support-files/mysql.server script itself; see also Section 2.10.2.2, “Starting and Stopping MySQL Automatically”.
  2. You can set up new accounts using the bin/mysql_setpermission script if you install the DBI and DBD::mysql Perl modules. For instructions, see Section 2.14, “Perl Installation Notes”.

After everything has been installed, you should test your distribution. To start the MySQL server, use the following command:

shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &

If that command fails immediately and prints mysqld ended, you can find some information in the host_name.err file in the data directory.

More information about mysqld_safe is given in Section 5.4.1, “mysqld_safe — MySQL Server Startup Script”.

Note: The accounts that are listed in the MySQL grant tables initially have no passwords. After starting the server, you should set up passwords for them using the instructions in Section 2.10, “Post-Installation Setup and Testing”.

修改mysql管理员密码,出现了如下问题:

[root@localhost mysql]# bin/mysqladmin -u root password '×××'

bin/mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

 

 

#如果你修改数据库密码是碰到了socket '/tmp/mysql.sock' 错误 ,则你需要执行下面这个命令,mysql安装后的mysql.sock默认路径是/var/lib/mysql/mysql.sock

[root@localhost mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

 

但修改完仍不好使。

相关阅读 更多 +
排行榜 更多 +
豆荚扫描

豆荚扫描

游戏工具 下载
音跃球球

音跃球球

音乐节奏 下载
小白追书绿色封面

小白追书绿色封面

浏览阅读 下载