Install, configure, and test the MySQL source code package in Linux (this test is feasible)

Source: Internet
Author: User

Install, configure, and test the MySQL source code package in Linux (this test is feasible)

Write down this MySQL note, which will be useful in the future! RedHat Linux 6 uses the CentOS yum source to describe how to install and configure mysql source code. Here we will continue with the configuration of php and Apache in the previous blog. Now we will write the configuration of MySQL. Lamp is successfully built here!

Notes for installing Apache source code:

Notes for installing PHP source code:

Now, you can write the MySQL source code installation and configuration:

1. Install mysql dependency:

Yum install cmake
Yum install ncurses-devel

2. Download the MySQL source code installation package and decompress it:
Mysql: http://distfiles.macports.org/mysql5/

Tar-zxvf mysql-5.5.21.tar.gz

3. Create the mysql installation directory and database storage directory

Mkdir-p/work/installed/mysql installation directory

Mkdir-p/work/installed/mysql/data database storage directory

4. Create mysql users and user groups

Groupadd mysql
Useradd-r-g mysql

5. Install MySQL:

Go to the decompressed package folder and 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-variables = 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-variables = 1

Among them:/work/installed/mysql is the installation directory of MySQL, which can be customized and installed wherever you like.

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 the character

-DEXTRA_CHARSETS = all // install all extended character sets

-DENABLED_LOCAL_INFILE = 1 // allow local data import

Run the following commands in sequence:

Make

Make install

If an error occurs:

Error :. /bin/mysqld: Character set 'utf8-DDEFAULT_COLLATION = utf8_general_ci 'is not a compiled character set and is not specified in the'/work/installed/mysql/share/charsets/Index. xml 'file

Error :. /bin/mysqld: Character set 'utf8-DDEFAULT_COLLATION = utf8_general_ci 'is not a compiled character set and is not specified in the'/work/installed/mysql/share/charsets/Index. xml 'file

The character set conflicts with the character. Therefore, you must add the character and Character Set options during compilation and ensure compatibility! Modify compilation parameters:

Run the following command:

Cmake-DCMAKE_INSTALL_PREFIX =/work/installed/mysql-DEXTRA_CHARSETS = all-variables = 1-DWITH_READLINE = 1-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = bytes-rows = 1-DWITH_SSL =

Cmake-DCMAKE_INSTALL_PREFIX =/work/installed/mysql-DEXTRA_CHARSETS = all-variables = 1-DWITH_READLINE = 1-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = bytes-rows = 1-DWITH_SSL =

NOTE: If re-compilation or compilation fails:

Note:

During re-compilation, you need to clear the old object file and cache information.

# Make clean

# Rm-f CMakeCache.txt

# Rm-rf/etc/my. cnf

Then: make and make install.

6. Set Directory Permissions

Run the following command in the installed mysql directory:

Chown-R root: mysql. // set the owner of all files in the current directory to root and the owner group to mysql.

Chown-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 for the system database

Scripts/mysql_install_db -- user = mysql

9. Set Environment Variables

# Vi/root/. bash_profile

Add the following parameter in PATH = $ PATH: $ HOME/bin:

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

# Source/root/. bash_profile


10. Start mysql

Method 1:
Run the following command in the mysql installation directory to start MySQL:
./Bin/mysqld_safe -- user = mysql &

Startup logs are written in this file: The/work/installed/mysql/data/localhost. err directory varies by the user, and the installation directory of the user is different.

Method 2:
Cp support-files/mysql. server/etc/init. d/mysql // Add the mysql startup service to the System Service
# Service mysql. server start

# Service mysql. server stop

# Service mysql. server restart

In addition, the command to disable the MySQL service is:

Mysqladmin-u root-p shutdown

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

# Mysql-u root mysql

Mysql> use mysql;
Mysql> desc user;
Mysql> grant all privileges on *. * TO root @ "%" identified by "root"; // Add the remote connection capability TO the root user.
Mysql> update user set Password = password ('xxxxxx') where User = 'root'; // XXXX indicates the MySQL Password entered by the user, root User
Mysql> select Host, User, Password from user where User = 'root ';
Mysql> flush privileges;
Mysql> exit

Log On again: mysql-u root-p

If remote connection is not available, disable the firewall.
[Root @ rhel5 ~] #/Etc/rc. d/init. d/iptables stop

12. 12-1. Test MySQL and combine MySQL with php.

Log on to mysql: mysql-u root-p

Enter Password: mysql (enter your own mysql password)

Create a database, create a table, and insert data as follows:

Mysql> create database test1;
Mysql> use test1;
Mysql> create table student (id int (4) not null primary key auto_increment, name char (20 ));
Mysql> insert into student (name) values ('Tom ');

The TOM name is inserted here, and php is configured next, and the published homepage content is written as follows:

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 configured and installed based on your own situation. Previous PHP configuration:

Apache configuration:

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

This article permanently updates link: http://www.bkjia.com/Linux/2015-07/119785tm

Related Article

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.