How to compile and install MySQL database in CentOS

Source: Internet
Author: User
The following content is based on the CentOS6.0 operating system, and the MySQL installation version is v5.1.59. The following describes in detail how to compile and install MySQL through commands. Compile and install mysqlcd/usr/local/srctarzxvfmysql-5.1.59.tar.gzcdmysql-5.1.59./configure -- prefix =/usr/local

The following content is based on the CentOS 6.0 operating system, and the MySQL installation version is v5.1.59. The following describes how to compile and install MySQL through commands.

Compile and install mysql

Cd/usr/local/src

Tar zxvf mysql-5.1.59.tar.gz

Cd mysql-5.1.59

. /Configure -- prefix =/usr/local/mysql -- localstatedir =/usr/local/mysql/data/-- with-mysqld-ldflags =-all-static -- with-client-ldflags =-all-static -- with-unix-socket-path =/tmp/mysql. sock -- with-shared -- without-debug -- with-extra-charsets = all -- without-embedded-server -- enable-profiling -- enable-encryper -- enable-thread-safe-client -- with-server-suffix =-community -- with-extra-charset = utf8, gbk

Make

Make install

Note: During the make compilation process, if you see the following line on the screen, which is stuck there, you will not be able to get through for a long time. do not think it is a compilation error or the server
Stuck. you only need to stick to it. wait patiently for a few minutes and the compilation will be successful! Mysql compilation and installation tells us that everything will succeed if you stick to it!
Make [4]: Entering directory '/usr/local/src/mysql-5.1.59/mysql-test'

Groupadd mysql # Add a mysql Group

Useradd-g mysql-s/bin/false # Create a user mysql and add it to the mysql group. mysql users are not allowed to log on directly to the system.

Chown-R root/usr/local/mysql/# Allow root access

Chgrp-R mysql/usr/local/mysql/# Allow mysql group access

Cd/usr/local/mysql/# enter the mysql installation directory

Cp/usr/local/mysql/support-files/mysql. server/etc/rc. d/init. d/mysqld # Add Mysql to the system to start

Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf # Copy the configuration file (note: The/etc directory contains my by default. cnf, directly overwrite it)

Chmod 755/etc/init. d/mysqld # execution permission

Vi/etc/profile # add the mysql service to the system environment variable:

Add the following line at the end

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

The following two lines link the myslq library file to the default system location, so that you do not need to specify the mysql library file address when compiling software such as PHP.

Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql

Ln-s/usr/local/mysql/include/mysql/usr/include/mysql

/Usr/local/mysql/bin/mysql_install_db -- user = mysql & # generate mysql system database

/Usr/local/mysql/bin/mysqld_safe -- user = mysql & # start mysql

/Etc/rc. d/init. d/mysqld start # start

Chkconfig mysqld on # add to startup

Shutdown-r now # restart the system. wait until the system is restarted and continue to perform the following operations on the terminal command line.

Mysql_secure_installation # set the Mysql password

Press Y to enter the password twice as prompted.

Or directly change the password/usr/local/mysql/bin/mysqladmin-u root-p password "123456" # change the password

Service mysqld restart # restart

At this point, mysql installation is complete!

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.