Mysql compilation and installation _ MySQL

Source: Internet
Author: User
Mysql compilation and installation of bitsCN.com

Mysql compilation and installation

Compile and install

Preparations before compilation and installation:

Add a mysql account

# Useradd mysql

Objective: to avoid database initialization problems

Installation:

[Root @ www bin] # tar xvzf mysql-5.1.34.tar.gz-C/usr/local/src/

[Root @ www lamp] # cd/usr/local/src/

[Root @ www src] # D mysql-5.1.34/

[Root @ www mysql-5.1.34] #. /configure -- with-mysqld-user = mysql -- prefix =/usr/local/mysql -- with-extra-charsets = all -- exec-prefix =/usr/local/mysql -- -innodb

// Which identity is used to run the installation directory when mysql is running? by default, all character set installation directories will generate a bin table type.

[Root @ www mysql-5.1.34] # make & make install

Initialize the database:

[Root @ www mysql-5.1.34] # cd/usr/local/mysql/

[Root @ www mysql] # ls

Bin docs include lib libexec mysql-test share SQL-examples // The Directory should have a default var directory for storing mysql data, which can be generated only after database initialization.

[Root @ www mysql] # cd bin

[Root @ www bin] #./mysql_install_db for database initialization

Modify permissions:

[Root @ www mysql] # chown. mysql-R. // recursively modify the group of all files in the current directory (mysql installation directory) as the mysql Group

[Root @ www mysql] # ll-d. // view the details of the current directory-d. list the directories like other files instead of their contents

Drwxr-xr-x 11 root mysql 4096 12-25.

[Root @ www mysql] # chown mysql var-R // recursively modify the owner of the var directory as a mysql account

Start:

[Root @ www mysql] # cd bin/

[Root @ www bin] #./mysqld_safe -- user = mysql & // start mysql in the background

[Root @ www bin] # ps-e

22127 pts/1 00:00:00 mysqld_safe

22178 pts/1 00:00:00 mysqld

The two processes indicate that mysql has been started successfully.

After startup, a socket file is generated.

[Root @ www bin] # cd/tmp/

[Root @ www tmp] # ls mysql. sock

Mysql. sock

In/tmp, if this file exists, it also indicates that mysql has been started. without this file, mysql will not be started.

----------------

Modify environment variables:

Modify the environment variables in the home directory and execute commands in the mysql bin directory in any directory.

[Root @ www ~] # Vim. bash_profile

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

Make it take effect:

[Root @ www ~] # Source. bash_profile

Test:

[Root @ www ~] # Which mysqladmin

/Usr/local/mysql/bin/mysqladmin

[Root @ www ~] # Pkill mysql // kill processes with mysql

Another method for starting mysql: Copy the mysql startup script to init. d.

[Root @ www mysql] # pwd

/Usr/local/mysql/share/mysql

[Root @ www mysql] # cp mysql. server/etc/rc. d/init. d // you can change the name to mysqld.

[Root @ www mysql] # service mysql. server restart

--------------------

Troubleshooting:

If the database initialization fails, it may be due to the following reasons:

[Root @ www mysql] # grep mysql/etc/passwd first requires the mysql User

Mysql: x: 27: 27: MySQL Server:/var/lib/mysql:/bin/bash

[Root @ www mysql] #/etc/init. d/mysqld stop originally installed a mysql rpm Package and started. stop it first

Stop MySQL: [OK]

[Root @ www mysql] # rpm-q mysql uninstalls the originally installed rpm Package

Mysql-5.0.45-7.el5

[Root @ www mysql] # rpm-e mysql -- nodeps

[Root @ www bin] #./mysql_install_db

[Root @ www bin] # cd ..

[Root @ www mysql] # ls

Bin docs include lib libexec mysql-test share SQL-callback var

At this time, we can see that there is a var generated

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.