Cdhomemysql enters the installation directory binmysql_install_db -- usermysql creates the data table chown-Rroot as a mysql user.
Cd/home/mysql enter the installation directory bin/mysql_install_db -- user = mysql CREATE the data table chown-R root as the mysql user.
Download Page:
Go to the bottom of the page and find Source downloads. This is the Source code version. Download 1st tarballs.
Groupadd mysql
Create a user group named mysql
Useradd-g mysql
Create a user named mysql under the mysql user group
Gunzip | mysql-VERSION.tar.gz | tar-xvf-
Decompress the downloaded .gz File
Cd mysql-VERSION
Enter the decompressed directory
CFLAGS = "-O3-mcpu = pentium4" CXX = gcc CXXFLAGS = "-O3-march = pentium4-felide-constructors-fno-exceptions-fno-rtti ". /configure -- prefix =/home/mysql/-- without-debug -- with-unix-socket-path =/home/mysql/tmp/mysql. sock -- with-client-ldflags =-all-static -- with-mysqld-ldflags =-all-static -- enable-validator -- with-extra-charsets = gbk, gb2312, utf8 -- without-innodb -- without-isam -- with-pthread -- enable-thread-safe-client
Configure mysql
Gcc parameters:
-O3 \
-O
-O1
Optimization. For large functions, optimizing compilation takes a little more time and a considerable amount of memory.
Without the '-O' option, the compiler aims to reduce compilation overhead and enable debugging of compilation results. the statement is independent: If you stop a program with a breakpoint between two statements, you can assign a value to any variable, or point the program counter to another statement in the function body, and precisely obtain the expected results from the source program.
When the '-O' option is not used, only the variables declared with register are allocated with registers. The compilation result is slightly inferior to those without the'-O' option.
With the '-O' option, the compiler will try to reduce the size and execution time of the target code.
If the '-O' option is specified, the'-fthread-jumps 'and'-fdefer-pop' options are enabled. the '-fdelayed-branch' option is enabled on a machine with a delay slot. on a machine that supports debugging even if there is no frame pointer (frame pointer), the '-fomit-frame-pointer' option is enabled. other options may be enabled on some machines.
-O2
More optimizations. in addition to optimization options that involve space and speed switching, almost all optimization work is performed. for example, loop unrolling and inlining are not performed ). compared with the-O option, this option increases both the Compilation Time and the running effect of the generated code.
-O3
More optimizations. Apart from opening what-O2 does, it also opens the-finline-functions option.
-O0
Not optimized.
If multiple-O options are specified, the last option takes effect regardless of the number.
-Mcpu = pentium4 \ optimized compilation based on the CPU type, which can make your mysq performance better! Optional item lot: i386, i386, i586, i686, pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4, k6, k6-2, athlon, athlon-tbird, k6-3, athlon-xp, athlon-mp, winchip-c6, winchip2, c3.
-Fomit-frame-pointer \ for functions that do not require a stack pointer, the pointer is not saved in the register. Therefore, the code for storing and retrieving addresses can be ignored and registers can be used for common purposes. One option is enabled for all "-O" levels, but it is valid only when the debugger can run without relying on the stack pointer. We recommend that you set it explicitly without debugging.
Configure parameters:
-- Prefix =/home/mysql/\ specifies the installation directory
-- Without-debug \ remove debug mode
-- With-extra-charsets = gbk, gb2312, utf8 \ added support for gbk, gb2312, and utf8 Chinese Characters
-- With-pthread \ force use of the pthread Library (posix thread Library)
-- Enable-javaser \ use the assembly version of some character Functions
-- Enable-thread-safe-client \ compile the client in thread mode
-- With-client-ldflags =-all-static \ compile the client in pure static mode
-- With-mysqld-ldflags =-all-static \ compile the server in pure static mode
-- Without-isam \ removes the isam table type support, which is rarely used now. The isam table is a platform-dependent table.
-- Without-innodb \ remove innodb table support. innodb is a table that supports transaction processing and is suitable for enterprise-level applications.
Make
Compile
Make install
Install
Cp support-files/my-medium.cnf/etc/my. cnf
Copy the mysql configuration file to the/etc directory and rename it my. cnf
/Home/mysql has 5 my-xxxx.cnf files below
My-small.cnf minimum configuration installation, memory <= 64 M, minimum data
My-large.cnf memory = 512 M
My-medium.cnf 32 M <内存<64m,或者内存有128m,但是数据库与web服务器公用内存
My-huge.cnf 1G <内存<2g,服务器主要运行mysql
My-innodb-heavy-4G.cnf Max configuration installation with at least 4 GB memory
Cd/home/mysql
Go to the installation directory
Bin/mysql_install_db -- user = mysql
Create a data table as a mysql user
Chown-R root.
Set the owner of the mysql home directory (that is,/home/mysql) as the root user. This is a command in the official document, but it is strange that if you set the main directory owner of mysql as a root user, mysql cannot be started after running bin/mysqld_safe -- user = mysql. The problem lies in "permission". Run chown-R mysql. You can run the following command to start mysql normally. Is the official document incorrect? I hope you will discuss it together.
Chown-R mysql var
Set the owner of the var directory to a mysql user
Chgrp-R mysql.
Set the owner of the mysql main directory to the mysql user group (Note: Unlike the previous command, this command is used to grant permissions to the user group)
Bin/mysqld_safe -- user = mysql &
Start mysql. If everything is normal, no prompt will be displayed after running this command.
Bin/mysqladmin-u root password
Modify the password of the root user. Here, the root user refers to the root user of mysql, which has nothing to do with the root user of Linux. The green password is the new password you need to set. Remember!
Bin/mysql-u root-p
If it is normal, you can log on with this name. After you enter the password, the prompt "mysql>" appears, indicating that the logon is successful. Exit with the quit command
Run the following command to set mysql to run automatically upon startup:
Cd mysql-VERSION
Enter the decompressed directory again, that is, the source code directory.
Cp support-files/mysql. server/etc/init. d/mysql
Copy the mysql. server File to the/etc/init. d/directory and rename it mysql.
Chmod 755/etc/init. d/mysql
Grant the "execution" permission to the/etc/init. d/mysql file.
Chkconfig -- level 345 mysql on
Added to Automatic startup, with a running level of 3 4 5
Service mysql restart
Restart mysql Service
Q: Why do I prompt "connect fail: Can't connect to local Mysql server through socket '/home/MySQL/tmp/mysql. sock' (13)" When I connect to mysql using PHP )"
A: This is because PHP cannot normally connect to the Mysql socket, that is, the mysql. sock file. First, check whether the mysql. sock file exists in the/home/mysql/tmp/directory. If not, it may be that mysql is not started properly; If yes, it may be that the permission for the/home/mysql/tmp/directory is insufficient, use chmod 755/home/mysql/tmp to solve this problem.