Common installation method for MySQL database

Source: Internet
Author: User

Introduction to Installation Methods

MySQL database also occasionally used for a period of time, the specific use of features are relatively simple, no specific in-depth study. Most recently, when deploying Ineedle systems in a company, you often avoid the need to install Apache and MySQL databases. There are several ways to install MySQL in general: Source installation, repos installation (Apt-get or yum) mode, binary package installation (TAR package). Installing MySQL when deploying Ineedle systems is done in either Apt-get or Yum, and because there is no specific requirement for MySQL versions, it is generally used in this way to meet the requirements. Yum source installation Method Although faster (relative source installation), it is more convenient, do not deliberately download the MySQL file package, a command to install directly, but there are limitations: such as the version is not free to choose, and if a Linux system default source does not have MySQL, Also have to set up Yum source, before you can go to install use, not free; and have to mention a wonderful thing, the front-end time to the company's equipment installed CENTOS7 system, the default Yum source has no MySQL, as long as the MySQL official website to download and configure the source, And the source version is 5.7 version, the latest version, the new version is very strange, encountered a lot of problems, and finally got back to the 5.5 version. Source installation mode Although can be freely controlled, but the compilation speed is enough, patience of friends can use this way; we'll summarize the general installation method for binary package tar.gz.

Mysql

MySQL download best go to the official to download, there will be no problem with the package, and each version is relatively complete, can be downloaded according to their own requirements.
http://downloads.mysql.com/archives/community/
There are 5.0, 5.1, 5.5, 5.6, 5.7 and a series of versions, we can choose the appropriate version and platform according to our own needs, we choose the Linux generic "linux-generic" "5.1.40" version
Then according to the system platform CPU architecture, compiler and other information, select the appropriate package: mysql-5.1.40-linux-i686-glibc23.tar.gz
The links are as follows:
Http://downloads.mysql.com/archives/get/file/mysql-5.1.40-linux-i686-glibc23.tar.gz

MySQL Download

Download directory set to /usr/local/src
Cd/usr/local/src
wget http://downloads.mysql.com/archives/get/file/mysql-5.1.40-linux-i686-glibc23.tar.gz
MySQL Decompression
Tar zxvf/usr/local/src/mysql-5.1.40-linux-i686-glibc23.tar.gz

The extracted data is moved to /usr/local/mysql
MV mysql-5.1.40-linux-i686-glibc23/*/usr/local/mysql

Build MySQL User

Useradd-s/sbin/nologin MySQL

Initializing the database

Cd/usr/local/mysql
Mkdir-p/var/mysql/data;
Chown-r Mysql:mysql/var/mysql/data;
./scripts/mysql_install_db--user=mysql--datadir=/var/mysql/data

--user defines the owner of the database, the--datadir defines where the database is installed, and it is recommended to place the partition on a large space, which needs to be created on its own.
Error encountered:
./bin/mysqld:error while loading shared libraries:libaio.so.1:cannot open Shared object file:no such file or directory
Yum Install Libaio
Running successfully, there are 2 OK.

Copy configuration file

CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF

Copy the startup script file and modify its properties

CP Support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld

modifying startup scripts

Vim/etc/init.d/mysqld
There are "Datadir=/var/mysql/data"where modifications are required (the directory defined when the database was previously initialized)

Add the startup script to the system service entry and set the boot start to start MySQL

Chkconfig--add mysqld
Chkconfig mysqld on
Service mysqld Start

If not, please check the error log under/var/mysql/data/, which is usually the hostname. Err. The command to check if MySQL starts is:
PS aux | grep mysqld

Set environment variable Path

Vi/etc/profile
Add to:
Export path= $PATH:/usr/local/mysql/bin
Save exit:
Source/etc/profile

To set up a soft connection to a MySQL library file

Cd/usr/local/mysql;
Ln-s/usr/local/mysql/lib MySQL;
MV Mysql/usr/lib

View:
Ls/usr/lib/mysql

Set up MySQL development header file

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

View:
Ls/usr/include/mysql
Note: The above steps do not affect the operation of MySQL, but if you use the MySQL library in the C program, you must set the library path and the header file path.

Set the root password to use after starting MySQL. For information on how to set the root password, refer to the following article:
Http://www.cnblogs.com/liwei0526vip/p/4953811.html

Common installation method for MySQL database

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.