Install and upgrade mysql in LINUX under vm

Source: Internet
Author: User
Tags localhost mysql
There are three installation methods for mysql in Linux: 1. yumrpm2, source code installation 3. Binary installation the first installation method is not mentioned here. The upgrade method is mainly binary installation, very simple! Operating Platform CentOS5.5 I. yumrpm installation first, find the packages that can be installed (available on the Image site, here we use

There are three installation methods for mysql in Linux: 1. yum/rpm 2. Source Code installation 3. Binary Installation

The first installation method is not mentioned here. The upgrade method is mainly binary installation, which is very simple!

CentOS 5.5

I. yum/rpm Installation

First, find the package that can be installed (available on the Image site, which uses the linux image site of Shanghai Jiao Tong University)

[Root @ localhost ~] # Yum search mysql (through thisCommandFind the packages to be installed, mysql. i386 mysql-beNcH. i386, mysql-devel.i386, mysql-server.i386)
[Root @ localhost ~] # Yum-y install mysql. i386 mysql-bench.i386 mysql-devel.i386 mysql-server.i386 (this command can be very happy to install)

Ii. Binary Installation

[Root @ localhost ~] # Tar zxvf mysql-standard-5.0.16-linux-i686.tar.gz (Extract)

[Root @ localhost ~] #MvMysql-standard-5.0.16-linux-i686 // usr/local/
[Root @ localhost ~] #Cd/Usr/local/
[Root @ localhost local] #Ln-S mysql-standard-5.0.16-linux-i686/mysql
[Root @ localhost local] #Mkdir/Opt/mysql
[Root @ localhost local] #ChownMysql. mysql/opt/mysql/
[Root @ localhost mysql] #Cp-FpSuPport-FileS/my-mEdIum. cnf. sh my3307.cnf

[Root @ localhost mysql] # vi my3307.cnf (modify the following statement)


[Client]
# Password = your_password
Port = 3307
Socket =/tmp/mysql3307.sock
[Mysqld]
Port = 3307
Socket =/tmp/mysql3307.sock
BaSedIr =/usr/local/mysql
Datadir =/opt/mysql
[Root @ localhost mysql] #./scripts/mysql_install_db -- defaults-file =./my3307.cnf -- user = mysql (Database initialization)

[Root @ localhost mysql] # chown-R root. mysql.
[Root @ localhost bin] #./mysqld_safe -- defaults-file = ../my3307.cnf -- user = mysql & (start database)

[Root @ localhost bin] # netStat-Tulnp |Grep3307 (check that the startup is successful)
Tcp 0 0 0.0.0.0: 3307 0.0.0.0: * LISTEN 20511/mysqld

[Root @ localhost bin] #./mysql-uroot-S/tmp/mysql3307.sock (database connection)

Iii. Source Code Installation

[Root @ localhost ~] # Mkdir-p/opt/mysql5145/data/
[Root @ localhost mysql-5.1.59] # chown-R mysql. mysql/opt/mysql5145/

[Root @ localhost ~] # Tar zxvf mysql-5.1.59.tar.gz
[Root @ localhost ~] # Cd mysql-5.1.59

[Root @ localhost mysql-5.1.59] # yum-y install gcc *
[Root @ localhost mysql-5.1.59] # yum install ncurses-devel.i386
[Root @ localhost mysql-5.1.59] #./configure -- prefix =/opt/mysql5145/-- locaLsTatedir =/opt/mysql5145/data/-- with-plugins = innobase, partition
[Root @ localhost mysql-5.1.59] # make & make install
[Root @ localhost mysql5145] # cp-fp ~ /Mysql-5.1.59/support-files/my-small.cnf my5145.cnf
[Root @ localhost mysql5145] # vi my5145.cnf (modify the following part)

[Client]
# Password = your_password
Port = 3310
Socket =/tmp/mysql3310.sock
[Mysqld]
Port = 3310
Socket =/tmp/mysql3310.sock
Basedir =/opt/mysql5145/
Datadir =/opt/mysql5145/data

[Root @ localhost mysql5145] # chown-R mysql.
[Root @ localhost mysql5145] #Chgrp-R mysql.
[Root @ localhost mysql5145] #./bin/mysql_install_db -- defaults-file =./my5145.cnf -- user = mysql (initialize)
[Root @ localhost mysql5145] #./bin/mysqld_safe -- defaults-file =./my5145.cnf -- user = mysql & (start)
[Root @ localhost mysql5145] #Netstat-Tulnp | grep mysql (check that the startup is successful)
Tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN 20217/mysqld
Tcp 0 0 0.0.0.0: 3307 0.0.0.0: * LISTEN 20511/mysqld
Tcp 0 0 0.0.0.0: 3310 0.0.0.0: * LISTEN 16469/mysqld

[Root @ localhost mysql5145] #./bin/mysql-S/tmp/mysql3310.sock (connect to the database)

Iv. settings related to startup items (mysqld_multi)

[Root @ localhost opt] # mkdir mysql3388/
[Root @ localhost mysql] # cp-rfp mysql ../mysql3388/

[Root @ localhost ~] # Vi/etc/my. cnf
[Mysqld_multi]

Mysqld =/usr/local/mysql/bin/mysqld_safe
Mysqladmin =/usr/local/mysql/bin/mysqladmin

[Mysqld3388]

Port = 3388
Socket =/tmp/mysql3388.sock
Basedir =/usr/local/mysql
Datadir =/opt/mysql3388
[Root @ localhost ~] # Mysqld_multi start 3388 (configuration)

5. Simple mysql upgrade (for the first installation of step 2, that is, only one installation)

[Root @ localhost ~] # MysqlDuMp-uroot -- all-databases>/tmp/all. SQL (Backup action)

[Root @ localhost local] # tar zxvf mysql-6.0.3-alpha-linux-i686-glibc23.tar.gz

[Root @ localhost local] # ln-s mysql-6.0.3-alpha-linux-i686-glibc23 mysql

[Root @ localhost local] # cd mysql
[Root @ localhost local] # chown-R root.

[Root @ localhost local] # chgrp-R mysql.

[Root @ localhost local] # mysqladmin-uroot shutdown
[Root @ localhost local] # mysqld_safe -- user-mysql & (initialization)
[Root @ localhost local] # mysql-uroot-p (connection)


Conclusion: Experiment Summary

The preceding steps are continuous operations on a server. Therefore, different configuration files are used. The first one is/etc/my. cnf, the second is/usr/local/mysql/mysql3307.cnf, and the third is/opt/mysql3310.cnf for better differentiation! The second step needs to install GCC and make and ncurses-devel.i386, the lack of software compilation must be installed on the security requirements, the fourth step is to manage multiple mysql servers on one machine. Of course, it is only a small example. Step 5 is an upgrade solution for mysql with only binary data on the machine, of course, the yum upgrade method is very convenient! The previous binary installation of mysql was always unsuccessful because mysql has been installed in yum on the local machine. The configuration file is my. cnf is already in use, which leads to installation errors. You can specify your own configuration file! The setting here is just a framework, and many files and parameters in it need further configuration!

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.