[Arrangement] Use cmake to install MySql in Linux

Source: Internet
Author: User
Tags mysql command line

Address: http://www.cppblog.com/issay789/archive/2013/01/05/196967.html

I. Install M4

: Http://files.w3pc.com/download/mysql/m4-1.4.16.tar.gz

Ii. Install bison

: Http://files.w3pc.com/download/mysql/bison-2.7.tar.gz

3. Install cmake

: Http://files.w3pc.com/download/mysql/cmake-2.8.10.2.tar

4. Install MySQL

: Http://files.w3pc.com/download/mysql/mysql-5.5.23.tar.gz

 

1. Install M4 \ bison \ cmake

Download files

Wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz

Or wget http://files.w3pc.com/download/mysql/cmake-2.8.10.2.tar

Compile and install (install M4 \ bison in the same way as below)


Tar zxvf cmake-2.8.5.tar.gz
CD cmake-2.8.5
. Boostarp (execute the command if this command is available, otherwise it will be skipped)
Make
Make install
Cmake -- version

Ii. install and configure MySQL

Download files

Wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.14.tar.gz/from/ftp://ftp.ntu.edu.tw/pub/MySQL/

Or wget http://files.w3pc.com/download/mysql/mysql-5.5.23.tar.gz

Set Linux to automatically match Environment Variables

1. $ su # su enters Root

# Vi/etc/profile

Add the following statement at the end of the file:
Path = $ path:/sbin # append the/sbin directory after the PATH variable
Export Path = $ path:/sbin # Set the variable to global
Save and exit.
Exit root and run on the terminal
$ Source/etc/profile # The purpose of this command is to re-execute the modified initialization file to make it take effect immediately, without having to log out and re-register it. Enter ifconfig in the terminal to create users and groups.


Groupadd MySQL // create an msyql user and group
Useradd-G MySQL mysql-S/usr/sbin/nologin
Mkdir/usr/local/MySQL // create a directory
Mkdir/usr/local/MySQL/Data // data warehouse directory

Install MySQL

Tar-zxvf mysql-5.5.14.tar.gz
CD mysql-5.5.14
Cmake-dcmake_install_prefix =/usr/local/MySQL

PS: When cmake is used, you don't need to use so many parameters. You only need one-dcmake_install_prefix =/usr/local/MySQL. We can configure it in my. CNF. [Mysqld] to see if my. CNF after your copy has these settings.

Make & make install
If you need to change the configuration, then:

Make clean
Rm-F cmakecache.txt

Copy the configuration file

Cpsupport-files/my-medium.cnf/usr/local/MySQL/My. CNF

Set permissions

Chmod + x/usr/local/MySQL
Chown-r MYSQL: MySQL/usr/local/MySQL

Configure auto-start upon startup

CP/usr/local/MySQL/support-files/MySQL. Server/etc/init. d/MySQL
Chmod + x/etc/init. d/MySQL
Chkconfig -- list
// Update-rc.d for MySQL ults (/sbin/chkconfig -- add MySQL;/sbin/chkconfig MySQL on)
Chkconfig -- add MySQL
Chkconfig MySQL on
Chkconfig -- list MySQL

Modify my. CNF Configuration

Gedit/usr/local/MySQL/My. CNF
[Mysqld] Add:
Datadir =/usr/local/MySQL/Data
Default-storage-engine = MyISAM
Optional values:

Log-error =/usr/local/MySQL/mysql_error.log
PID-file =/usr/local/MySQL. PID
User = MySQL
Tmpdir =/tmp

Install default data tables

/Usr/local/MySQL/scripts/mysql_install_db -- basedir =/usr/local/MySQL -- datadir =/usr/local/MySQL/data -- user = MySQL

Start MySQL

/Usr/local/MySQL/bin/mysqld_safe -- defaults-file =/usr/local/MySQL/My. CNF &
The final "&" indicates running in the background, or starting with/etc/init. d/MySQL start (Service MySQL start)

Set the MySQL command line path
The path of the MySQL Command is under/usr/local/MySQL/bin. Therefore, when you directly use the MySQL Command, the system queries the command under/usr/bin.
Solution: ln-S/usr/local/MySQL/bin/MySQL/usr/bin

Test whether MySQL is started

1) check whether the MySQL process exists
PS-Ef | grep MySQL

2) check whether the port is running
Netstat-tnl | grep 3306

3) read MySQL version information
/Usr/local/MySQL/bin/mysqladmin version

So far, MySQL installation is complete.

Iii. troubleshooting
1. libstdc ++. So dependency problem: Use the command Yum install gcc

Iv. References

Http://laiguowei2004.blog.163.com/blog/static/3682900020117834131998/
Http://hi.baidu.com/reducm/blog/item/1ad30a2b71e691215243c13d.html
Http://www.cnblogs.com/vicowong/archive/2011/01/27/1946453.html
Http://noohou.sinaapp.com/

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.