Install MySQL5.5 (single instance) in the source code of CentOS)

Source: Internet
Author: User

Install MySQL5.5 (single instance) in the source code of CentOS)

1. Media preparation

Note: Due to the CMAKE Method Used for MySQL5.5 source code compilation, download the cmake installation package and the MySQL5.5 installation package in advance.

As follows:
Http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/
Http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz

After the download is complete, upload the file to the specified server.

2. Install the dependency package

There are many dependency packages to be installed in CentOS, so we recommend that you install them using yum source. In fact, many packages are optional. (The bold font must be installed)
Yum-y install gcc * gcc-c ++ * autoconf * automake * zlib * libxml * ncurses-devel * libgcrypt * libtool *

3. Create a mysql user

[Root @ localhost ~] # Groupadd mysql # Add a mysql user group
[Root @ localhost ~] # Useradd mysql-g mysql-s/sbin/nologin #
Add a mysql user

4. Create an installation directory and grant permissions

Installation path:/opt/mysql
Database path:/opt/mysql/data
Source code package storage location:/project


Mkdir-p/opt/mysql/data

Chown-R mysql. mysql/opt/mysql


5. Install the cmake compilation tool
Tar zxvf cmake-2.8.4.tar.gz
Cd cmake-2.8.4
./Configure
Make
Make install
Note: After the installation is complete, it is best to add cmake to/etc/profilea.
PATH =/projects/cmake-2.8.10.2/bin: $ PATH
Export PATH
6. decompress the source package and enter the directory.
Tar xzvf mysql-5.5.33-linux2.6-x86_64.tar.gz
Cd mysql-5.5.33-linux2.6-x86_64
7. Compile and install and configure compilation Parameters
Compilation tips: it is best to create a project under the source code directory and compile it in the project so that the source code and compilation can be clearly divided.
[Root @ localhost ~] # Cmake...-DCMAKE_INSTALL_PREFIX =/opt/mysql \
-DMYSQL_UNIX_ADDR =/opt/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/opt/mysql/data /\
-DMYSQL_TCP_PORT = 3306
[Root @ localhost ~] # Make & make install

After completing the above seven steps, mysql has been installed. Now we will introduce the database initialization file and configuration startup.
8. Set the environment variable and add the mysql command to the PATH. What I demonstrate is to add it ~ /. Bash_profile. You can also add it to/etc/profile.
PATH =/opt/mysql/bin: $ PATH: $ HOME/bin

Source ~ /. Bash_profile

9. Add the mysql configuration file to the/etc directory.
[Root @ localhost ~] # Cp support-files/my-small.cnf/etc/my. cnf # mysql configuration file

[Root @ localhost ~] # Chmod 755 scripts/mysql_install_db # grant the execution permission of mysql_install_db
[Root @ localhost ~] # Scripts/mysql_install_db -- user = mysql -- basedir =/opt/mysql -- datadir =/opt/mysql/data/
If two OK words are displayed, the initialization is successful.


Add mysql to System Service
[Root @ localhost ~] # Cp support-files/mysql. server/etc/init. d/mysqld
[Root @ localhost ~] # Chmod 755/etc/init. d/mysqld
10. Start the mysql Service
Service mysqld start
11. Add the mysql account password
Mysqladmin-u root password 'yourpassword'
Mysql has two account types: localhost and %. The former allows the local machine to connect to mysql, and the latter can be used to remotely connect to mysql on other machines.

Finally, handle account logon issues so that the root account password can be used locally and remotely.
[Root @ localhost ~] #/Usr/local/mysql/bin/mysql-u root-p # After you press this command, the screen will prompt you to enter the password and enter yourpassword set in the previous step.
Delete records with empty root passwords
Mysql> use mysql;
Mysql> delete from user where password = '';
Mysql> flush privileges;
Configure mysql to allow root remote login # Login
Mysql> grant all privileges on *. * to root @ '%' identified by "root ";
Mysql> flush privileges;
End;

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

How to install and configure MySQL5.7.3.0

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 the link address:

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.