Install mysql5.5 using MySQL Binary Package Based on Linux

Source: Internet
Author: User
Preface

MySQL has been used for some time. However, installation of MySQL is based on the software source on Linux, and then started conveniently using the shell of MySQL, I do not know much about MySQL internal startup parameters, So I download the tar package of MySQL from the MySQL official website, install and start it on my own, and understand MySQLProgramTo help you troubleshoot the startup process and learn more about MySQL.

Environment

Ubuntu 12.04 32bit

Download MySQL

1. Download: Download mysql-5.5.28-linux2.6-i686.tar.gz at http://dev.mysql.com/downloads/mysql/.

2. Extract

 
Tar-Xvf mysql-5.5.28-Linux2.6-I686.Tar. GZ

3. Move to/usr/local/MySQL

MVMysql-5.5.28-Linux2.6-I686/usr/local/Ln-S mysql-5.5.28-Linux2.6-I686/MySQL

4. Install the dependent lib package: Run/usr/local/bin/MySQL/bin/mysqld, and an error is returned.

 
/Usr/local/MySQL/bin/mysqld: ErrorWhileLoading shared libraries: libaio. So.1: Cannot open sharedObject File: No suchFileOr directory

Use apt-cache search libaio to find the following software source:

Libaio-Dev-Linux kernel AIO access library-Development fileslibaio1-Linux kernel AIO access library-Shared librarylibaio1-Dbg-Linux kernel AIO access library-debugging symbols

Use apt-Get install libaio1.

 

Configure users and directories
 
Shell>Groupadd mysqlshell> Useradd-r-G MySQL mysqlshell> Cd/usr/local/Mysqlshell>Chown-R mysql. Shell>Chgrp-R MySQL.

 

Initialize MySQL
Shell> scripts/mysql_install_db -- user =MySQL
# Next command is optionalshell>CPSupport-files/my-medium.cnf/etc/My. CNF
 
# Next command is optionalshell>CPSupport-files/MySQL. Server/etc/init. d/MySQL. Server

The most important thing here is to initialize some MySQL permission account tables. A root user with an empty password is created by default.

 

Start MySQL

The simplest startup method:

 
Shell>/Usr/local/MySQL/bin/mysqld -- user = MySQL

By default,/usr/local/MySQL/data is used as the MySQL data directory, including database files and log logs.

 

Common MySQL startup parameters:

/Usr/local/MySQL/bin/mysqld -- user = MySQL -- basedir =/usr/local/MySQL -- datadir =/usr/local/MySQL/data -- Port =3306-- Socket =/tmp/MySQL. Sock

 

Recommended MySQL startup

 
/Usr/local/MySQL/support-files/MySQL. Server start

Generally, the above script is used to start the MySQL server, which can be added to the Linux system service.

 

Disable MySQL

The simplest way

 
KillallMysqld

Recommended Methods

 
/Usr/local/MySQL/support-files/MySQL. server stop

Using mysql. server stop to close mysqld will destroy the PID file and perform fault tolerance operations. However, the kill command kill MySQL is also called.

Close mysql. Do not use kill-9 mysql_pid or killall-9 mysql. Otherwise, the MySQL process may lose data or even cause table corruption.

 

 

Analysis of MySQL. server script Startup Process

MySQL. server script can be seen in the following script to call the bash mysqld_safe

 
$ Bindir/mysqld_safe -- datadir ="$ Datadir"-- PID-File="$ Mysqld_pid_file_path"$ Other_args>/dev/Null 2> &1&

By default, $ bindir/mysqld_safe is the shell/usr/local/MySQL/bin/mysqld_safe. The call parameters of my local machine are as follows:

 
/Bin/Sh/Usr/local/MySQL/bin/mysqld_safe -- datadir =/usr/local/MySQL/data -- PID-File=/Usr/local/MySQL/data/blue-pc.pid

Mysqld_safe is also a shell. You can see that after this script initializes n multiple variables, it calls

 
Eval_log_error"$ Cmd"

This shell function is called at last.

 
#Echo "Running mysqld: [$ cmd]"Eval"$ Cmd"

On my local machine, $ cmd is

 
/Usr/local/MySQL/bin/mysqld -- basedir =/usr/local/MySQL -- datadir =/usr/local/MySQL/data -- Plugin-Dir=/Usr/local/MySQL/lib/plugin -- user = MySQL -- log-error =/usr/local/MySQL/data/blue-pc.err -- PID-File=/Usr/local/MySQL/data/blue-pc.pid

 

Reference http://dev.mysql.com/doc/refman/5.5/en/binary-installation.html

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.