Mysql source code distribution & amp; #8203; detailed installation process _ MySQL

Source: Internet
Author: User
Tags configuration settings mysql commands unpack
Mysql source code distribution version: amp; #8203; detailed installation process: bitsCN.com The following is a more detailed description of installing the MySQL source code distribution version:
1. add a logon user and group for mysqld:
2. shell> groupadd mysql3. shell> useradd-g mysql commands will add mysql groups and MySQL users. In Unix of different versions, the syntax of useradd and groupadd may be slightly different. It can also be called adduser and addgroup.
You may name these users and groups out of mysql. If so, replace it with the corresponding name in the following steps.
4. select a directory where you want to unbind the package and go to the directory.
5. obtain a distribution file from one of the sites listed in Section 2.1.3 "how to get MySQL.
6. unpack the distribution version under the current directory:
7. shell> gunzip </path/to/mysql-VERSION.tar.gz | tar xvf-this command creates the mysql-VERSION directory.
If you use GNU tar, you no longer need gunzip. You can use the following command to unpack and extract distribution:
Shell> tar zxvf/path/to/mysql-VERSION-OS.tar.gz8. go to the top-level Directory of the unpack distribution:
9. shell> cd mysql-VERSION. Currently, you must configure and build MySQL from the top-level Directory. You cannot build in other directories.
10. configure the release version and compile it:
11. shell>. /configure -- prefix =/usr/local/mysql12. shell> make when you run configure, you may want to specify some options to run. /configure -- help to get a list of options. Section 2.8.2, "typical configuration options" describes some useful options.
If configure fails, you will send emails containing all rows in "config. log" that you think can help you solve the problem, and the last row of configure output. Use the mysqlbug script to mail the error report. See section 1.7.1.3, "How to report defects and problems ".
If compilation fails, see section 2.8.4, "handling MySQL compilation problems" for help.
13. install the distribution edition:
14. shell> make install if you want to set an option file, use one of the support-files directories as the template. For example:
Shell> cp support-files/my-medium.cnf/etc/my. cnf you may need to run these commands with the root user.
If you want to configure InnoDB tables to be supported, edit the/etc/my. cnf file, remove the # character before the innodb _... start option line, and change the option value to what you want. See Section 4.3.2, "use option file" and section 15.2.3, "InnoDB configuration ".
15. go to the installation directory:
16. shell> cd/usr/local/mysql17. if you have not installed MySQL, you must create the MySQL authorization table:
18. shell> bin/mysql_install_db -- user = mysql if you use root to run the command, you should use the -- user option. The option value should be the same as the login account you created for the running server in the first step. If you use this user to log on to run the command, you can omit the -- user option.
After creating the MySQL authorization table using mysql_install_db, you need to manually restart the server
19. change the binary ownership of the program to root, and change the ownership of the data directory to the user you run mysqld. If you are in the installation directory (/usr/local/mysql), the command should be:
20. shell> chown-R root. 21. shell> chown-R mysql var22. shell> chgrp-R mysql. the First Command changes all the attributes of the file to the root user. The second command changes all the attributes of the data directory to the mysql User. The third command changes the group attribute to the mysql group.
23. if you like to automatically start MySQL when booting the machine, you can copy the support-files/mysql. server file to a place where your system has a startup file. For more information, see support-files/mysql. server script and section 2.9.2.2, "automatically start and stop MySQL.
24. if the DBI and DBD: mysql Perl modules are installed, you can use the bin/mysql_setpermission script to add a new account. For more information, see Section 2.13, "notes for installing Perl ".
After everything is installed, you should use this command to initialize and test your distribution:
Shell>/usr/local/mysql/bin/mysqld_safe -- user = mysql & if this command prompts mysqld daemon ended and fails immediately, then you can file "hostname' in the data directory '. err "finds some information.
For more information about mysqld_safe, see section 5.1.3, "mysqld_safe: MySQL server startup script ".
Note: The account in the MySQL authorization table does not have a password. After starting the server, you should use the instructions in Section 2.9, "setup and test after installation" to set the password.
2.8.2. The configure script for typical configuration options gives you a lot of control over how to configure the MySQL source code distribution. The configure command line is generally used. You can also use some environment variables to act on configure. See Appendix F: environment variables. To view the list of options supported by configure, run the following command:
Shell>./configure -- help if you only compile the MySQL client library and client program instead of the server, use the -- without-server option:
Shell>./configure -- without-server
If you do not have a C ++ compiler, you cannot compile mysql (there is a client program that requires C ++ ). In this case, you can remove the code used to test the C ++ compiler in configure, and then run./configure with the -- without-server option. The compilation step will still try to construct mysql, but you can ignore any warning about "mysql. cc. (If make stops, try make-k to tell it to continue the remaining construction steps even if an error occurs ).
· If you want to build an embedded MySQL Library (libmysqld. a), you should use the -- with-embedded-server option.
If you do not want to store the log files and databases in the/usr/local/var Directory, use one of the following configure commands:
Shell>./configure -- prefix =/usr/local/mysql
Shell>./configure -- prefix =/usr/local-
Localstatedir =/usr/local/mysql/data
The first command changes the installation prefix so that all content can be installed under "/usr/local/mysql" instead of the default "/usr/local ". The second command retains the default installation prefix, but overwrites the default Database Directory (usually "/usr/local/var") and changes it to/usr/local/mysql/data. After compiling MySQL, you can use the option file to change these options. See Section 4.3.2, "use option File ".
If you are using Unix and want the MySQL socket to be located somewhere outside the default location (usually in the directory "/tmp" or "/var/run ", use the configure command like this:
Shell>./configure/-- with-unix-socket-
Path =/usr/local/mysql/tmp/mysql. sock
Note that the given file name must be an absolute path. You can also use the MySQL option file to change the location of mysql. sock in the future. See section A.4.5, "How to protect or change the MySQL socket file/tmp/mysql. sock ".
If you want to compile a static link program (for example, to make a binary distribution version, to get faster or to solve some problems with the RedHat distribution version), run configure like this:
· Shell>./configure -- with-client-ldflags =-all-static/
· -- With-mysqld-ldflags =-all-static
If you are using gcc and do not have libg ++ or libstdc ++ installed, you can tell configure to use gcc as the C ++ compiler:
Shell> CC = gcc CXX = gcc./configure
When you use gcc as the C ++ compiler, it will not try to link libg ++ or libstdc ++. Even if you have installed these libraries, this is good because some of their versions encountered some strange problems when using MySQL in the past.
The following lists some frequently used compiler and environment variable settings.
O gcc 2.7.2:
O CC = gcc CXX = gcc CXXFLAGS = "-O3-felide-constructors" o egcs 1.0.3a:
O CC = gcc CXX = gcc CXXFLAGS = "-O3-felide-constructors/o-fno-exceptions-fno-rtti" o gcc 2.95.2:
O CFLAGS = "-O3-mpentiumpro" CXX = gcc CXXFLAGS = "-O3-mpentiumpro/o-felide-constructors-fno-exceptions-fno-rtti" o pgcc 2.90.29 or a newer version:
O CFLAGS = "-O3-mpentiumpro-mstack-align-double" CXX = gcc/o CXXFLAGS = "-O3-mpentiumpro-mstack-align-double/o-felide-constructors- fno-exceptions-fno-rtti "in most cases, use the options listed earlier in configure and add the following options to obtain a reasonably optimized MySQL binary:
-- Prefix =/usr/local/mysql -- enable-validator/-- with-mysqld-ldflags =-all-static in other words, for all recent gcc versions, the entire configure row should be:
CFLAGS = "-O3-mpentiumpro" CXX = gcc CXXFLAGS = "-O3-mpentiumpro/-felide-constructors-fno-exceptions-fno-rtti ". /configure/-- prefix =/usr/local/mysql -- enable-plugin ER/-- with-mysqld-ldflags =-all-static at the MySQL website. See section 2.1.2.5, "MySQL binary version compiled by MySQL AB ". There are some configuration settings, which can be used to build faster binary, but only for advanced users. See section 7.5.4, "How compilation and link affect MySQL speed ".
If the construction fails and an error related to the compiler or Linker is generated, you cannot create a shared library "libmysqlclient. so. # "(" # "is a version number). you can solve this problem by specifying the -- disable-shared option for configure. In this case, configure will not construct a shared libmysqlclient. so. # Library.
By default, MySQL uses the latin1 (cp1252) character set. To change the default settings, use the -- with-charset option:
Shell>./configure -- with-charset = CHARSET
CHARSET can be big5, cp1251, cp1257, czech, danish, dec8, dos, euc_kr, gb2312, gbk, german1, hebrew, hp8, hungarian, koi8_ru, primary, latin1, latin2, sjis, swe7, tis620, ujis, usa7, or win1251ukr. See section 5.10.1, "character set for data and sorting ".
You can specify the default checking rules. MySQL uses latin1_swedish_ci by default. To change the value, use the -- with-collation option:
Shell>./configure -- with-collation = COLLATION to change the character set and collation, use the -- with-charset and -- with-collation options at the same time. The collation must be a valid collation for character sets. (Use the show collation statement to determine which Verification rule is used for each character set ).
If you want to change characters between the server and the client, you should take a look at the set option character set command. See section 13.5.3 "SET Syntax ".
Warning if you change the character set after creating any database table, you must run myisamchk-r-q -- set-character-set = charset for each table, otherwise, the index may be incorrectly sorted. (If MySQL is installed, create tables, reconfigure MySQL to use a different character set, and reinstall it, this may happen .)
Using the configure option -- with-extra-charsets = LIST, you can define which character sets can be further defined on the server. LIST refers to any of the following items:
O character set names with spaces
O complex-to include all character sets that cannot be dynamically loaded
O all-to include all character sets in binary
To configure MySQL with debugging code, use the -- with-debug option:
Shell>./configure -- with-debug
This results in a safe memory distributor that can discover some errors and provide output about what is happening. See section E.1, "debug MySQL server ".
· If the client program uses a thread, you must use the -- enable-thread-safe-client configuration option to compile the MySQL client library of the thread Security Edition. A libmysqlclient_r library will be created to connect to the application thread. See section 25.2.15, "how to generate a line program Client ".
· You can use the -- with-big-tables option to build MySQL that supports large database tables.
This option enables the variable to save the number of rows in the table to unsigned long instead of unsigned long. The result is that the table is allowed to have approximately 1.844E + 19 (232) 2) rows instead of 232 (~ 4.295E + 09. Previously, to complete this function, you must manually pass-DBIG_TABLES to the compiler.
The options for a specific system can be found in the specific system section in this chapter. See section 2.12, "precautions related to operating systems" bitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.