MySQL Source package manual installation, configuration and testing (pro-test feasible)

Source: Internet
Author: User
Tags check character php source code

Note Editor: wavelet/qq463431476 Blog Home: http://www.cnblogs.com/xiaobo-Linux/

Make a note of this MySQL note and look forward to useful later!

REDHAT6 uses the CentOS yum source to explain MySQL's source installation and configuration. Here continue on to the blog Php,apache configuration, now write MySQL configuration. Lamp built to this success!

Apache Source Installation Notes: http://www.cnblogs.com/xiaobo-Linux/p/4637056.html

PHP Source Installation Notes: http://www.cnblogs.com/xiaobo-Linux/p/4637775.html

Now start to write MySQL source installation and configuration:

1. Install MySQL dependency:

Yum install Cmakeyum install ncurses-devel

2, download the MySQL source installation package and unzip:

MySQL:  http://distfiles.macports.org/mysql5/ 
TAR-ZXVF  mysql-5.5.  tar.gz.

3. Create MySQL installation directory and database storage directory

Mkdir-p/work/installed/mysql   installation directory               -p/work/installed/mysql/data  Database storage Directory

4. Create MySQL users and user groups

Groupadd MySQL
Useradd-r-G MySQL MySQL

5. Install MySQL:

Go to unpack folder to execute:

CMake. -dcmake_install_prefix=/work/installed/mysql -dmysql_datadir=/work/installed/mysql/data  - Ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dextra_charsets=all-denabled_local_infile=1

CMake. -dcmake_install_prefix=/work/installed/mysql-dmysql_datadir=/work/installed/mysql/data-ddefault_charset= Utf8-ddefault_collation=utf8_general_ci-dextra_charsets=all-denabled_local_infile=1

Where:/work/installed/mysql for the installation directory of MySQL, this can be customized, you like to install where to install.

parameter Description:-dcmake_install_prefix=/usr/local/mysql        // installation directory -dinstall_datadir=/ usr/local/mysql/data         // Database storage directory -ddefault_charset=utf8                    //  Use the UTF8 character -ddefault_collation=utf8_general_ci            // check character -dextra_charsets=all                        // Install all extended character sets -denabled_local_infile=1  // allow import of data from local          

Follow the following sequence:

Makemake Install

If an error occurs:

File

Error:./bin/mysqld:character set ' Utf8-ddefault_collation=utf8_general_ci ' is not a compiled Character set and was not speci Fied in the '/work/installed/mysql/share/charsets/index.xml ' file

is a character set and character conflict, so when compiling the character and character set options are added, and to be compatible! To modify the compilation parameters:

Then execute this command:

Cmake-dcmake_install_prefix=/work/installed/mysql-dextra_charsets=all-denabled_local_infile=1-dwith_readline=1 -ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_embedded_server=1-dwith_ssl=system

Cmake-dcmake_install_prefix=/work/installed/mysql-dextra_charsets=all-denabled_local_infile=1-dwith_readline=1 -ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_embedded_server=1-dwith_ssl=system

Note that if you recompile or compile an error:

Note: When recompiling, you need to clear the old object file and cache information. # make clean# rm-f cmakecache.txt# rm-rf/etc/my.cnf

Then: make, make install.

6. Set directory Permissions

Execute the command under the installed MySQL directory:

-R root:mysql.  // Set the owner owner of all files in the current directory to root, and the owning group is MySQL-R mysql:mysql Data
7. Add the MySQL startup service to the system service
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
8. Create a table of system databases
scripts/mysql_install_db--user=mysql

9. Setting Environment variables

# Vi/root/.bash_profile

In Path=$PATH:$HOME/bin add parameters as:

Path=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib

Source/root/.bash_profile

10. Start MySQL

Act 1:
execute in MySQL-installed directory to start MySQL:
./bin/mysqld_safe-- User=mysql &

Startup log is written under this file:/work/installed/mysql/data/localhost.err directory varies by person , your own installation directory

Method 2:
CP support-files/mysql.server /etc/init.d/mysql //< Span style= "color: #008000;" > add the MySQL startup service to the system service
# service Mysql.server start 

# Service mysql.server Stop

# service mysql.server Restart

Additionally, the command to close the MySQL service is:
mysqladmin-u root-p shutdown

11. Modify the password of the root user of MySQL and open the remote connection

# Mysql-u Root MySQL

Mysql>use MySQL;
Mysql>desc user;
Mysql> GRANT All privileges on * * to [email protected]"%"root "; The ability to add remote connections for root.
Mysql>update user Set Password = Password (' xxxxxx ') where user= ' root '; Here xxxx for their own input MySQL password, the root user

Mysql>flush privileges;
Mysql>exit

Re-login: Mysql-u root-p

If remote connections are not yet in progress, turn off the firewall
[[email protected] rhel5~] # /etc/rc.d/init.d/iptables stop

12, 12-1, test MySQL and combine MySQL with PHP

Login Mysql:mysql-u Root-p

Enter password: MySQL (enter the MySQL password you set)

Set up a database, create a table, insert data:

mysql> CREATE DATABASE Test1;mysql> Use test1;mysqlint(4null  Char(()); MySQL> INSERT into student (name) VALUES ('Tom');    

Tom's name is inserted here, then PHP is configured, and the page content of the publication is written:

Reconfigure PHP:

./configure--prefix=/work/installed/php  --with-apxs2=/work/installed/apache/bin/apxs--with-mysqli=/work/ Installed/mysql/bin/mysql_config

Here the PHP installation path is the original configuration installed, according to their own circumstances. Previous PHP Configuration: http://www.cnblogs.com/xiaobo-Linux/p/4637775.html

Apache Configuration: http://www.cnblogs.com/xiaobo-Linux/p/4637056.html

Then in the PHP source code decompression package to execute:

Make

Make install

Last reboot Apache: Execute restart in Apache installed directory:/work/installed/apache/bin/apachectl restart

12-2. Write index.php This file in the directory of Apache's publishing home page.

My publishing directory is:/home/web/index.php

Write Php:vim index.php:

The purpose of this is to show the data that Tom has just inserted:

<?PHP $mysql=NewMySQL (); $mysql->connect ('localhost','Root','MySQL','test1'); //Create a query$sqlstr ='SELECT * FROM Student'; //send a query to MySQL$result = $mysqlquery ($SQLSTR);  while($row = $resultFetch_object ()) {$name= $rowname;    Echo $name; }?>

Restart Apache again:

./apachectl Restart

If Tom's words show that MySQL is successful!

To this MySQL installation is complete! Lamp===apache+mysql+php also build success!

MySQL Source package manual installation, configuration and testing (pro-test feasible)

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.