compilation, installation, configuration of mysql5.5 in centos6.6

Source: Internet
Author: User

Today, according to the requirements to compile the installation of centos6.6 on the mysql5.5, because the previous compilation and installation felt very simple, but today there is a little problem, so the installation process summed up a bit:

It seems like starting from mysql5.5 to compile and install MySQL requires the CMake tool to compile and install, since it is a compilation installation, it is necessary to use some dependent class libraries and related compiler tools, so you need to install the relevant tools beforehand.

First, compile and install

1. Install the dependencies required during MySQL compilation and compile the tools (you need to configure the Yum source first)

# yum-y Install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-de Vel zlib zlib-devel glibc glibc-devel glib2 glib2-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl cur L-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel Bison cmake

2. Installing the CMake compilation tool with Yum

#yum-y Install CMake

3. Before installation, you need to check if MySQL is installed, if any, uninstall

# Rpm-qa | grep MySQL

4. Download the MySQL source package and unzip

# tar XVF Mysql-mysql-5.5.35.t15.tar

Or extract to the specified directory (for example:/usr/local)

# tar xvf mysql-mysql-5.5.35.t15.tar-c/usr/local

5. Go to MySQL's unzip directory, compile, install with CMake

# CD MYSQL-MYSQL-5.5.35.T15

1) compile with cmake (choose compile parameters according to your specific requirements, the option parameters below are for reference only)

#cmake \

-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/usr/local/mysql/data \

-DSYSCONFDIR=/ETC \

-dmysql_unix_addr=/var/lib/mysql/mysql.sock \

-ddefault_charset=utf8 \

-ddefault_collation=utf8_general_ci

2) Installation

#make && make Install

Wait a minute ...

6. Need to create MySQL user and MySQL group and modify the user and group of MySQL installation directory

1) Create MySQL user and MySQL group

#groupadd MySQL

#useradd-G mysql-s/sbin/nologin MySQL

2) Modify the user and group to which the MySQL installation directory belongs

#chown-R Mysql:mysql/usr/local/mysql

7. Go to MySQL installation directory, execute initialization script, create MySQL database and table

# Cd/usr/local/mysql

# CD scripts/

#./mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql

If Utf8_general_ci error occurs, in/etc/my.cnf [mysqld] Character_set_server=utf8

[client] Default-character-set = UTF8

8. Modify the configuration file

# VI/ETC/MY.CNF

9. Add the service, set the MySQL service to start

1) Add the service, enter the MySQL installation directory, copy the Mysql.server file under directory/support-files to the/etc/init.d/directory, and rename it to MySQL

#cd/usr/local/mysql

#cp Support-files/mysql.server/etc/init.d/mysql

2) Set power on Start

# chkconfig MySQL on

10. Start the MySQL service

11. The compiled and installed MySQL does not have an initial password, so set the initial password for the root user

#/usr/local/mysql/bin/mysqladmin-u root password ' 123456 '

12. Because manually compiled, all to add environment variables for MySQL, or enter MySQL in the terminal will prompt the command can not find

1) Edit/etc/profile, add the following at the end of the file

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

Such as:

2) make the file effective immediately

#source/etc/profile

13. Now the MySQL installation configuration is basically complete, you can go to login, use

If it appears when logged on: Error 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2) errors

can modify/ETC/MY.CNF

Add the following content:

[Client]

Socket=/var/lib/mysql/mysql.sock

Such as:

14. If you want other remote hosts to access the MySQL, you can do the following

Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' password ' with GRANT OPTION;

Alternatively, you can modify the user table in the MySQL library to add the specified host

15. Because the firewall does not turn on port 3306 by default, you need to manually turn on this port

Edit/etc/sysconfig/iptables

Add the following content

-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

16. At this point we can look at the host, users and other information allowed to access the database

Go to MySQL library to view user table information

Mysql>use MySQL

Mysql>select Host,user,password from user;

You can see the two passwords we set separately (local access to MySQL root user password and remote access to MySQL root user's password)

If you need to specify that some hosts can access the database, you can modify the table to add the IP of the specified host to the table.

17. If you want to change the default port for the database, you need to change the configuration file/etc/my.cnf

Add the following content:

Port: Port number

For example:

Then restart the MySQL service

#service MySQL Restart

Note: If you modify the default port number here, the port number that the firewall allows to access is also changed to match the port number in this file

18. If there is a slow connection to MySQL in the LAN, it may be related to the DNS reverse resolution of MySQL, you can turn off this function

To modify the file/etc/my.cnf, add the following:

Skip-name-resolve

Such as:

Restart the MySQL service.

compilation, installation, configuration of mysql5.5 in centos6.6

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.