mysql5.5 compile-free installation and script start error in depth

Source: Internet
Author: User
Tags mysql free mysql in

Mysql Introduction to Installation Environment:

I'm doing MHA recently. Already installed heartbeat and DRBD, now ready to install MySQL.

Mysql installation directory:/opt/mysql

Mysql Data Catalog:/data/mysql


Note: The/data directory is actually a disk partition that DRBD needs to synchronize to the standby node

[Email protected] src]# df-h

Filesystem Size used Avail use% mounted on

/dev/sda2 9.5G 2.0G 7.1G 22%/

Tmpfs 932M 0 932M 0%/dev/shm

/DEV/SDA1 190M 58M 123M 32%/boot

/dev/drbd0 19G 832M 17G 5%/data


One, MySQL free compilation installation (you can directly copy the command line to execute or save to the shell script)

#1 , decompression configuration

Yum Install-y libaio-devel

Cd/usr/local/src

[!-F mysql-5.5.49-linux2.6-x86_64.tar.gz ] && \

wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz

Tar zxf mysql-5.5.49-linux2.6-x86_64.tar.gz

mkdir/opt/

mv mysql-5.5.49-linux2.6-x86_64 /opt/mysql-5.5.49

Ln-s/opt/mysql-5.5.49/opt/mysql

#2 , create users

if! ID Mysql;then

Useradd mysql-s/sbin/nologin-m

Fi

# can write down:! ID mysql && useradd mysql-s/sbin/nologin-m # # # # #

#还有一种脱裤子放屁的做法.

#groupadd MySQL

#useradd-G mysql-m MySQL

MySQL group is created when #用useradd MySQL, and I don't know why I added the group first

#3 , initializing the database, single-instance startup

/opt/mysql/scripts/mysql_install_db--datadir=/data/mysql--basedir=/opt/mysql--user=mysql

Cp/etc/my.cnf/etc/my.cnf.ori

Grep-ev "#|^$"/OPT/MYSQL/SUPPORT-FILES/MY-INNODB-HEAVY-4G.CNF >/etc/my.cnf

Cp/opt/mysql/support-files/mysql.server/etc/init.d/mysqld

Chkconfig mysqld on

#chmod +x/etc/init.d/mysqld (default already has X permission)


#4, adding environment variables

echo "Path=/opt/mysql/bin: $PATH" >>/etc/profile

. /etc/profile


#4, modify/ETC/MY.CNF or/etc/init.d/mysqld (temporarily do not modify, let the script start error)

Basedir=/opt/mysql

Datadir=/data/mysql

***************************************************************************************

1 , installation Errors

[Email protected] src]#/opt/mysql/scripts/mysql_install_db--datadir=/data/mysql--basedir=/opt/mysql--user=mysql

Installing MySQL system tables ...

/opt/mysql/bin/mysqld: errorwhile loading shared libraries:libaio.so.1:cannot Open Shared object File:nosuch file O R directory

Solution: Yum install-y libaio-devel

2 , start error 1: Basedir and DataDir not specified

[[email protected] src] #service mysqld start

/etc/init.d/mysqld:line 256:my_print_defaults:command NotFound

/etc/init.d/mysqld:line 276:CD:/usr/local/mysql:no suchfile or directory

Starting MySQL error! Couldn ' t find MySQL server (/usr/local/mysql/bin/mysqld_safe)


3, start error 2

If Basedir=/opt/mysql is specified, but datadir= is empty, startup will error.

[[email protected] src] #service mysqld restart

error! MySQL server PID file could not befound!

Starting mysql.error! The server quit without updating PID file (/opt/mysql/data/mysql1.pid).

[[email protected] src] #vi/etc/init.d/mysqld

4, start error 3

And neither Basedir nor DataDir have specified.

[[email protected] src] #service mysqld restart

/etc/init.d/mysqld:line 256:my_print_defaults:command not found

/etc/init.d/mysqld:line 256:my_print_defaults:command not found

error! MySQL server PID file could not befound!

/etc/init.d/mysqld:line 256:my_print_defaults:command not found

/etc/init.d/mysqld:line 276:CD:/usr/local/mysql:no such file or directory

Starting mysqlerror! Couldn ' t find MySQL server (/usr/local/mysql/bin/mysqld_safe)

***********************************************************************************




A few days ago to solve the production environment of the foot of the problem, now the error analysis of the principle of the following:

Take a look at the/etc/init.d/mysqld startup script below for an explanation of the bold section.

# If You install MySQL in some other placesthan/usr/local/mysql and then you

# The following things for Thisscript and work:

#

#-Run Thisscript from within the MySQL installation directory

#-Create a/etc/my.cnf file with the following information:

# [mysqld]

# Basedir=<path-to-mysql-installation-directory>

#-ADD The Aboveto any other configuration file (for example ~/.my.ini)

# and copy my_print_defaults To/usr/bin

#-Add The Pathto the mysql-installation-directory to the Basedir variable

# below.

#

# If you want toaffect other MySQL variables, you should make your changes

# in THE/ETC/MY.CNF, ~/.my.cnf or other MySQL configuration files.

# If You changebase dir, your must also change datadir. These may get

# If You changebase dir, your must also change datadir. These may get

# overwritten Bysettings in the MySQL configuration files.

Basedir=

Datadir=

# Default Value,in seconds, afterwhich the script should timeout waiting

# for ServerStart.

# Value here Isoverriden by Value in MY.CNF.

# 0 means don ' twait at all

# negative Numbersmean to wait indefinitely

service_startup_timeout=900

# Lock Directoryfor Redhat/suse.

Lockdir= '/var/lock/subsys '

Lock_file_path= "$lockdir/mysql"

# The Followingvariables is only set for letting Mysql.server find things.

# Set Somedefaults

Mysqld_pid_file_path=

If Test-z "$basedir"

Then

Basedir=/usr/local/mysql

Bindir=/usr/local/mysql/bin

If Test-z "$datadir"

Then

Datadir=/usr/local/mysql/data

Fi

Sbindir=/usr/local/mysql/bin

Libexecdir=/usr/local/mysql/bin

Else

Bindir= "$basedir/bin"

If Test-z "$datadir"

Else

Bindir= "$basedir/bin"

If Test-z "$datadir"

Then

Datadir= "$basedir/data"

Fi

Sbindir= "$basedir/sbin"

Libexecdir= "$basedir/libexec"

Fi


Translation:

1. If Basedir does not specify a MySQL installation path, the startup script will start with/usr/local/mysql as the installation path. So MySQL is not installed under/usr/local, boot must fail

2. If basedir=/opt/mysql specifies the MySQL installation path, and the path to MySQL installation is in/opt/mysql case. When datadir= is empty, the startup script will $basedir/data (that is,/opt/mysql/data) as the MySQL data directory. Usually we are used to put the data directory under/data/mysql. At this point the boot will error:

Starting MySQL. error! The server quit without Updatingpid file (/opt/mysql/data/mysql1.pid).

3, Summary: When starting with/etc/init.d/mysql, it is best to set the value of Basedir and DataDir in/etc/init.d/mysqld. or add it under [Mysqld] in/etc/my.cnf.

[Mysqld]

#port = 3306

Socket =/tmp/mysql.sock

Basedir=/opt/mysql

Datadir=/data/mysql


I don't know if I can say it clearly. We recommend that you look at the MySQL startup script file again.

Experience: MySQL recently encountered a lot of problems, fortunately most of the errors can be found through the log on Baidu. Explains the fiery level of MySQL use and the spirit of sharing

This article is from the "Linux Learning Notes" blog, reproduced please contact the author!

mysql5.5 compile-free installation and script start error in depth

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.