Installation source code package in linux( tar.gz)

Source: Internet
Author: User

Quick installation steps:

  shell> groupadd mysql     shell> useradd -g mysql mysql     shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -     shell> cd mysql-VERSION     shell> ./configure --prefix=/usr/local/mysql     shell> make     shell> make install     shell> cp support-files/my-medium.cnf /etc/my.cnf     shell> cd /usr/local/mysql     shell> bin/mysql_install_db --user=mysql     shell> chown -R root  .     shell> chown -R mysql var     shell> chgrp -R mysql .     shell> bin/mysqld_safe --user=mysql &


Shell explanation:

This operation is described in Linux Shell environment. For example, when logging on to Linux Using SSH or telnet, you can see:

For example

[root@guigu home]# 

Now let's take a closer look at what he is doing ~

shell> groupadd mysqlshell> useradd -g mysql mysql

Groupadd and useradd are commands for creating user groups and users in Linux. The preceding commands allow us to create MySQL groups and users respectively.

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

Gunzip is the decompression command in Linux. commands with the same functions, such as tar, can be used at will based on your preferences. Refer to the command:

tar -zvxf mysql-4.1.18.tar.gz

 

shell> cd mysql-VERSION

BecauseInstall-SourceThe file will appear in different versions of the file package. The prompt here is to enter the folder of the current version. For details, refer:

1.cd mysql-4.1.18

 

Next we will go to the pre-compilation Configuration:

shell> ./configure --prefix=/usr/local/mysql

./Configure is an essential part of the Linux environment before compiling. Besides a few programs, it will also be prompted in the installation documentation, but it is rare.

The above command will specify that the newly installed MySQL will be installed in the/usr/local/MySQL folder.

Tip 1: before installation, check whether the MySQL folder already exists in the/usr/local folder.

Tip 2: Change the default character set is specified here. If your program needs to use utf8 or gb2312, use the following:

 

./configure --prefix=/usr/local/mysql --with-charset=gb2312

Tip 1: replace gb2312 with GBK or utf8.

Tip 2: If we still need other character sets based on the existing ones, we should add extended character sets. refer to the following:

./Configure -- prefix =/usr/local/MySQL -- With-charset = gb2312 -- With-extra-charsets = GBK, utf8

Note: The default character set is gb2312, but both GBK and utf8 are supported.

Usage: GBK and utf8 encoding. When creating a database, You must select a character set and add the set names GBK to the program, for example, set names GBK.

shell> make

Make: Compilation takes some time to complete, depending on the running speed of the computer you are using. The general condition is 10 ~ 30 minutes.

Tip: If your Linux installation is relatively complete, the compilation usually runs normally without worrying.

The software related to compilation is the GCC compiler, but this problem has rarely occurred as an existing Linux release version.

shell> make install

Complete the compilation and copy the compilation results to the corresponding location correctly.

shell> cp support-files/my-medium.cnf /etc/my.cnf

This command is to copy the mysql-4.1.18 file in support-files in the my-medium.cnf source folder to the/etc folder and rename it to my. CNF

Tip: Support-files provides the configuration files required for different environments, such:

My-small.cnf/* If the system memory is less than 64 MB, You need to select this file
My-medium.cnf/* If the system memory is greater than 128 MB, you can select this file
My-large.cnf/* If the system memory is 512 MB, select this file
My-huge.cnf/* If the system memory is 1 GB ~ 2G. Select this file
My-innodb-heavy-4G.cnf/* If the system memory is 4 GB memory-transaction, you can select this file

Note: One of the options of the above files must be noted, as follows:

# Try Number of CPU's * 2 for thread_concurrency
Thread_concurrency = 2

The thread_concurrency value is the number of CPUs used by your computer X2

shell> cd /usr/local/mysqlshell> bin/mysql_install_db --user=mysql

Go to the MySQL directory that you just installed, and run mysql_install_db -- user = MySql in the bin folder.

Initialize the MySQL database

shell> chown -R root  .shell> chown -R mysql varshell> chgrp -R mysql .

Use the chown and chgrp commands to set attributes of MySQL folders and sub-files. For example:

Chown MySQL xxx

The xxx folder can only be read by the root user

Chgrp MySQL xxx

The xxx folder can only be read by mysql users.

Note:-R contains subfolders and files.

Shell> bin/mysqld_safe -- user = MySQL &

Start the MySQL database and run it as a MySQL user.

About database security stop:

Many people do not know how to stop the database-kill and kill it. It is actually wrong, but few people pay attention to it and there is no relevant information on the Internet:

1. Use mysqladmin

Mysqladmin-u root-P Shutdown

2. There is a file mysql. server in the support-Files Folder. We can use the following command to set the file:

  1. Chmod + x mysql. Server

Then copy it to the folder to be placed, for example, CP mysql. Server/etc/init. d.

Call:

  1. /Etc/init. d/MySQL. server stop

As shown above, MySQL compilation has been completed in Linux. For more information about how to properly use MySQL, see the phpMyAdmin series in the incubator.

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.