`
爱像天空
  • 浏览: 197380 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

mysql-5.0.67编译安装

阅读更多
mysql-5.0.67编译安装

从http://www.sfr-fresh.com/unix/misc/mysql-5.0.67.tar.gz/下载源代码包;
将mysql-5.0.67.tar.gz放到指定的目录下,解压tar zxvf mysql-5.0.67.tar.gz;

shell> groupadd mysql 创建mysql用户组


shell> useradd -g mysql mysql创建mysql用户


进入mysql-5.0.67,
./configure --prefix=/usr/local/mysql  --with-innodb ,支持innodb引擎

然后make , make install



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

编辑/etc/my.cnf文件

cd /usr/local/mysql,


chown -R mysql .
chgrp -R mysql .


bin/mysql_install_db --user=mysql --force

如果在执行这一步时出错,很可能是对某些文件没有读写权限。


chown -R root .
chown -R mysql var


成功后运行mysql:

bin/mysqld_safe --user=mysql &


# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

解决方法:
先停掉mysql服务;
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql  //用root登录mysql,并且使用mysql数据库
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
重新启动mysql
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
以上这个方法针对的是mysql数据库中存在user表记录的情况来修改root的密码,如果连user表都是空的,则不适合用此方法。但是,如果user数据表是空的,则可以插入一个用户记录。

我采用的方法如下:

使用mysqldump从其他机器导出user表的记录,然后用mysqlimport导入到本地数据库中:

mysqldump -uroot mysql user -T /data/user/

然后从/data/user目录中将user.txt拷贝到本地的/data/user目录,执行:

mysqlimport -uroot mysql /data/user/user.txt

然后就可以直接使用./mysql登录了。

说明文档:



The Database Usage dialog allows you to indicate the storage engines that you expect to use when creating MySQL tables. The option you choose determines whether the InnoDB storage engine is available  and  what  percentage of the server resources are available to InnoDB.

   MySQL Server Configuration Wizard: Usage Dialog

     * Multifunctional Database: This option enables both the InnoDB

       and  MyISAM storage engines and divides resources evenly

       between the two. This option is recommended for users who use

       both storage engines on a regular basis.

     * Transactional Database Only: This option enables both the

       InnoDB and MyISAM storage engines, but dedicates most server

       resources  to  the InnoDB storage engine. This option is

       recommended for users who use InnoDB almost exclusively and

       make only minimal use of MyISAM.

     * Non-Transactional Database Only: This option disables the

       InnoDB storage engine completely and dedicates all server

       resources  to  the MyISAM storage engine. This option is

       recommended for users who do not use InnoDB.

The Configuration Wizard uses a template to generate the server configuration file. The Database Usage dialog sets one of the following option strings:

Multifunctional Database:        MIXED

Transactional Database Only:     INNODB

Non-Transactional Database Only: MYISAM

When these options are processed through the default template (my-template.ini) the result is:

Multifunctional Database:

default-storage-engine=InnoDB

_myisam_pct=50

Transactional Database Only:

default-storage-engine=InnoDB

_myisam_pct=5

Non-Transactional Database Only:

default-storage-engine=MyISAM

_myisam_pct=100

skip-innodb

The _myisam_pct value is used to calculate the percentage of resources  dedicated  to MyISAM. The remaining resources are allocated to InnoDB.

The Character Set Dialog

   The  MySQL server supports multiple character sets and it is possible to set a default server character set that is applied to all tables, columns, and databases unless overridden. Use the    Character Set dialog to change the default character set of the MySQL server.

   MySQL Server Configuration Wizard: Character Set

     * Standard Character Set: Choose this option if you want to use

       latin1 as the default server character set. latin1 is used for

       English and many Western European languages.

     * Best Support For Multilingualism: Choose this option if you

       want to use utf8 as the default server character set. This is

       a Unicode character set that can store characters from many

       different languages.

     * Manual Selected Default Character Set / Collation: Choose this

       option if you want to pick the server's default character set

       manually. Choose the desired character set from the provided

       drop-down list.

MySQL Installation Using a Source Distribution

   This section does not apply to MySQL Enterprise Server users.

   Before you proceed with an installation from source, first check whether our binary is available for your platform and whether it works for you. We put a great deal of effort into ensuring that our binaries are built with the best possible options.

   To obtain a source distribution for MySQL, Section 2.4.4, "How to Get MySQL." If you want to build MySQL from source on Windows, see Section 2.4.15.6, "Installing MySQL from Source on Windows."

   MySQL source distributions are provided as compressed tar archives and have names of the form mysql-VERSION.tar.gz, where VERSION is a number like 5.0.68.

   You need the following tools to build and install MySQL from source:

     * GNU gunzip to uncompress the distribution.

     * A reasonable tar to unpack the distribution. GNU tar is known   to work. Some operating systems come with a preinstalled version of tar that is known to have problems. For example, the tar provided with early versions of Mac OS X tar, SunOS 4.x and Solaris 8 and earlier are known to have problems with long filenames. On Mac OS X, you can use the preinstalled gnutar program. On other systems with a deficient tar, you should install GNU tar first.

     * A working ANSI C++ compiler. gcc 2.95.2 or later, SGI C++, and SunPro C++ are some of the compilers that are known to work. libg++ is not needed when using gcc. gcc 2.7.x has a bug that makes it impossible to compile some perfectly legal C++ files, such as sql/sql_base.cc. If you have only gcc 2.7.x, you must upgrade your gcc to be able to compile MySQL. gcc 2.8.1 is      also known to have problems on some platforms, so it should be avoided if a newer compiler exists for the platform. Gcc 2.95.2 or later is recommended.

     * A good make program. GNU make is always recommended and is sometimes required. (BSD make fails, and vendor-provided make implementations may fail as well.) If you have problems, we recommend GNU make 3.75 or newer.

     * libtool 1.5.24 or later is also recommended.

   If you are using a version of gcc recent enough to understand the -fno-exceptions option, it is very important that you use this option. Otherwise, you may compile a binary that crashes randomly.

   We also recommend that you use -felide-constructors and -fno-rtti long with -fno-exceptions. When in doubt, do the following:

CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \

       -fno-exceptions -fno-rtti" ./configure \

       --prefix=/usr/local/mysql --enable-assembler \

       --with-mysqld-ldflags=-all-static

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> chown -R mysql .

shell> chgrp -R mysql .

shell> bin/mysql_install_db --user=mysql --force

shell> chown -R root .

shell> chown -R mysql var

shell> bin/mysqld_safe --user=mysql &

Note

   This procedure does not set up any passwords for MySQL accounts. After  following  the  procedure, proceed to Section 2.4.16, "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:

shell> groupadd mysql

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.

    2. Perform the following steps as the mysql user, except as noted.

    3. Pick  the  directory  under which you want to unpack the distribution and change location into it.

    4. Obtain a distribution file using the instructions in Section 2.4.4, "How to Get MySQL."

    5. Unpack the distribution into the current directory:

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

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

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.

    7. Configure the release and compile everything:

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

shell> make

       When  you run configure, you might want to specify otheroptions. Run ./configure --help for a list of options. Section

       2.4.15.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.7, "How to Report Bugs or Problems." If the compile fails, see Section 2.4.15.4, "Dealing with Problems Compiling MySQL," for help.

    8. Install the distribution:

shell> make install

       You might need to run this command as root. 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 this command 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.2.3.2, "Using Option Files," and Section 13.2.3, "InnoDB Configuration."

    9. Change location into the installation directory:

shell> cd /usr/local/mysql

   10. If you ran the make install command as root, the installed files will be owned by root. Ensure that the installation is accessible to mysql by executing the following commands as root in the installation directory:

shell> chown -R mysql .

shell> chgrp -R mysql .

       The first command changes the owner attribute of the files to the mysql user. The second changes the group attribute to the mysql group.

   11. If you have not installed MySQL before, you must create the MySQL data directory and initialize the grant tables:

shell> bin/mysql_install_db --user=mysql

       If you run the command as root, include the --user option as shown. If you run the command while logged in as mysql, you can omit the --user option. The command should create the data directory and its contents with mysql as the owner.

       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.

   12. Most of the MySQL installation can be owned by root if you like. The exception is that the data directory must be owned by mysql. To accomplish this, run the following commands as   root in the installation directory:

shell> chown -R root .

shell> chown -R mysql var

   13. 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.4.16.2.2, "Starting andStopping MySQL Automatically."

   14. You can set up new accounts using the bin/mysql_setpermission script if you install the DBI and DBD::mysql Perl modules. See Section 4.6.16, "mysql_setpermission --- Interactively Set Permissions in Grant Tables." For Perl module installation instructions, see Section 2.4.21, "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 you run the command as root, you should use the --user option as shown. The value of the option is 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.

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

Building MySQL from the Standard Source Distribution

   This section does not apply to MySQL Enterprise Server users.

   You can build MySQL on Windows by using a combination of cmake and Microsoft Visual Studio .NET 2003 (7.1), Micrsofot Visual Studio 2005 (8.0) or Microsoft Visual C++ 2005 Express Edition. You must have the appropriate Microsoft Platform SDK installed.

Note

   To  compile from the source code usin CMake you must use the standard source distribution (for example, mysql-5.0.45.tar.gz). You build from the same distribution as sed to build MySQL on Unix, Linux and other platforms. Do not use the Windows Source distributions as they do not contain the necessary configuration script and other files.

   Follow this procedure to build MySQL:

    1. If you are installing from a packaged source distribution, create a work directory (for example, C:\workdir), and unpack the source distribution there using WinZip or another Windows       tool that can read .zip files. This directory is the work directory in the following instructions.

    2. If you are installing from a Bazaar tree, the root directory of  that  tree  is  the  work directory in the following instructions.

    3. Using a command shell, navigate to the work directory and run the following command:

C:\workdir>win\configure options

       These options are available:

          + WITH_INNOBASE_STORAGE_ENGINE: Enable the InnoDB storage engine.

          + WITH_PARTITION_STORAGE_ENGINE:  Enable user-defined partitioning.

          + WITH_ARCHIVE_STORAGE_ENGINE: Enable the ARCHIVE storage engine.

          + WITH_BLACKHOLE_STORAGE_ENGINE: Enable the BLACKHOLE storage engine.

          + WITH_EXAMPLE_STORAGE_ENGINE: Enable the EXAMPLE storage engine.

          + WITH_FEDERATED_STORAGE_ENGINE: Enable the FEDERATED  storage engine.

          + __NT__: Enable support for named pipes.

          + MYSQL_SERVER_SUFFIX=suffix: Server suffix, default none.

          + COMPILATION_COMMENT=comment: Server comment, default"Source distribution".

          + MYSQL_TCP_PORT=port: Server port, default 3306.

          + DISABLE_GRANT_OPTIONS: Disables the the --bootstrap, --skip-grant-tables, and --init-file options for mysqld.

            This option is available as of MySQL 5.0.36.

       For example (type the command on one line):

C:\workdir>win\configure WITH_INNOBASE_STORAGE_ENGINE             WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro

    4. From the work directory, execute the win\build-vs8.bat or win\build-vs71.bat file, depending on the version of Visual Studio you have installed. The script invokes CMake, whichgenerates the mysql.sln solution file you will need to build MySQL using Visual Studio.. You can also use win\build-vs8_x64.bat to build the 64-bit version of MySQL. However, you cannot build the 64-bit version with Visual Studio Express Edition. You must use Visual Studio  2005 (8.0) or higher.

    5. From the work directory, open the generated mysql.sln file with Visual Studio and select the proper configuration using the Configuration menu. The menu provides Debug, Release, RelwithDebInfo, MinRelInfo options. Then select Solution >

       Build to build the solution. The build process will take some time. Please be patient.  Remember the configuration that you use in this step. It is important later when you run the test script because thatscript needs to know which configuration you used.

    6. You should test you build before installation. See Section 2.4.15.6.4, "Testing a Windows Source Build."

    7. To  install, use the instructions in Section 2.4.15.6.3, "Installing MySQL from a Source Build
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics