Install lamp (2) in Ubuntu 11.10 source code

Source: Internet
Author: User

I. Preliminary equipment work:

1. Download http://www.mysql.com/downloads/mysql/from the official website. Then, select Source code from the drop-down box and download the last one:

Generic Linux (Architecture independent), compressed

Tar archive

(Mysql-5.5.20.tar.gz)

2. Install the cmake component

sudo apt-get install cmake

3. Install libncurses5-dev Components

sudo apt-get install libncurses5-dev

4. Install the GCC-C ++ component

sudo apt-get install build-essential

5. Install the bison component

sudo apt-get install bison

Ii. Compilation and Installation

In this version of mysql5.5, the compilation tool was changed from autotool to cmake, And the MySQL team also wrote an article autotools to cmake transition guide. The compilation parameters to be listed in this article can also be found in this article.

sudo groupadd mysqlsudo useradd -r -g mysql mysqlsudo tar -zxf mysql-5.5.20.tar.gz -C /usr/localcd /usr/local/mysql-5.5.20sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DWITH_DEBUG=0 -DWITH_INNOBASE_STORAGE_ENGINE=1sudo makesudo make install

If all the components prepared in the earlier stage are installed, no problems will occur during compilation and installation,

Parameter description:

Parameter fan name Description
Dcmake_install_prefix Installation path
Dmysql_datadir Database path
Ddefault_charset Default character
Ddefault_collation Default Character Set
Dmysql_unix_addr Connect to the database socket path
Dwith_debug Indicates whether to enable debug mode, bool Value

Iii. Configuration

After the installation is complete, we also need to configure it accordingly.

cd /usr/local/mysqlsudo chown -R mysql .sudo chgrp -R mysql .sudo ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --no-defaults

Be sure to add the final parameter -- no-defaults. Without this parameter, the program will automatically load the default configuration file, and you have not completed the preparation of the configuration file, so it is likely to cause errors.

After the configuration is complete, you need to modify the permissions for security considerations.

sudo chown -R root .sudo chown -R mysql data

Next, we will configure the my. CNF file. First, you should know the order in which MySQL looks for configuration files. The initial search location is/etc/My. CNF, And then/etc/MySQL/My. CNF. Therefore, we need to put the configuration file in one of the above two locations.

sudo cp ./support-files/my-medium.cnf /etc/my.cnf

Configure My. CNF information:

Find the corresponding location of mysqld and append the following information.

[mysqld]user = mysqlbasedir = /usr/local/mysqldatadir  = /usr/local/mysql/datacharacter-set-server = utf8

Copy mysql. server to/etc/init. d:

sudo cp ./support-files/mysql.server /etc/init.d/mysql

Start MySQL database:

sudo /etc/init.d/mysql start

Check whether MySQL is successfully started:

sudo /usr/local/mysql/bin/mysqladmin version

If you see the following information, it indicates that the operation is successful.

/Usr/local/MySQL/bin/mysqladmin ver 8.42 distrib 5.5.20, for Linux on x86_64
Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Server version 5.5.20-Log
Protocol version 10
Connection localhost via UNIX socket
UNIX socket/tmp/mysqld. Sock
Uptime: 1 min 51 sec

Threads: 1 questions: 2 Slow queries: 0 opens: 33 flush tables: 1 open tables: 26 queries per second AVG: 0.018

Set soft link:

cd /usr/local/mysql/binsudo ln -s /usr/local/mysql/bin/mysql /usr/binsudo ln -s /usr/local/mysql/bin/mysqladmin /usr/binsudo ln -s /usr/local/mysql/bin/mysqldump /usr/bin

Set the password for the root user:

mysqladmin -u root password '111111'

Enter the database:

mysql -u root -p

Prompt data password. Enter the correct password and enter MySQL. Success !!!!!

4. Set to start MySQL at startup

sudo sysv-rc-conf

Find the MySQL location, and then select [3] [4] [5.

V. Basic MySQL Information

Path Description
/Var/run/mysqld This directory stores socket and process files
/Var/lib/MySQL This directory stores database data files, starts and closes logs, and bin-Log

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.