Install MySQL in CentOS

Source: Internet
Author: User

 

1. software acquisition

You can obtain a stable version of mysql5.1.58 from the official website. Select souce code to download the package installation file.

If the host is directly connected to the public network, you can use the following method to obtain the software package on the host:

Wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.58.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/

 

2. Installation Method

1) decompress the Software Package

Tar xvf mysql-5.1.58.tar.gz

 

2) configure a mysql user

Useradd-d/home/mysql

 

Edit the. bash_profile of a mysql user

#. Bash_profile

 

# Get the aliases and functions

If [-f ~ /. Bashrc]; then

.~ /. Bashrc

Fi

 

# User specific environment and startup programs

 

PATH = $ PATH: $ HOME/bin:/sbin

Export PATH

Export PS1 = "[\ u @ \ h \ w] \ $"

 

 

3) configuration, compilation, compilation, and installation

./Configure -- prefix =/home/mysql /\

-- With-unix-socket-path =/home/mysql. sock \

-- With-big-tables \

-- With-charset = utf8 \

-- With-collation = utf8_general_ci \

-- With-extra-charsets = gbk, gb2312, utf8 \

-- With-client-ldflags =-all-static \

-- With-mysqld-ldflags =-all-static \

-- With-plugins = partition, innobase, myisammrg \

-- With-pthread \

-- With-readline \

-- Without-debug \

-- Without-isam \

-- Enable-Cycler \

-- Enable-local-infile \

-- Enable-thread-safe-client

 

Make

 

Make install

 

4) create a MySQL database

Before creating a database, edit the my. cnf file. Put the my. cnf file under the MySQL installation directory (/home/mysql ). The content of the my. cnf file is as follows:

[Client]

# Character-set-server = utf8

Port = 3306

Socket =/tmp/mysql. sock

 

[Mysqld]

Character-set-server = utf8

Replicate-ignore-db = mysql

Replicate-ignore-db = test

Replicate-ignore-db = information_schema

User = mysql

Port = 3306

Socket =/tmp/mysql. sock

Basedir =/home/mysql

Datadir =/home/mysql/data

Log-error =/home/mysql/log/error. log

Pid-file =/home/mysql. pid

Open_files_limit = 10240

Back_log = 600

Max_connections = 5000

Max_connect_errorrs = 6000

Table_cache = 614

External-locking = FALSE

Max_allowed_packet = 32 M

Sort_buffer_size = 1 M

Join_buffer_size = 1 M

Thread _ cache_size = 300

# Thread_concurrency = 8

Query_cache_size = 512 M

Query_cache_limit = 2 M

Query_cache_min_res_unit = 2 k

Default-storage-engine = MyISAM

Thread_stack = 192 K

Transaction_isolation = READ-COMMITTED

Tmp_table_size = 246 M

Max_heap_table_size = 246 M

Long_query_time = 3

Log-slave-updates

Log-bin =/home/mysql/log/binlog

Binlog_cache_size = 4 M

Binlog_format = MIXED

Max_binlog_cache_size = 8 M

Max_binlog_size = 1G

Relay-log-index =/home/mysql/log/relaylog

Relay-log-info-file =/home/mysql/log/relaylog

Relay-log =/home/mysql/log/relaylog

Expire_logs_days = 30

Key_buffer_size = 256 M

Read_buffer_size = 1 M

Read_rnd_buffer_size = 16 M

Bulk_insert_buffer_size = 64 M

Myisam_sort_buffer_size = 128 M

Myisam_max_sort_file_size = 10G

Myisam_repair_threads = 1

Myisam_recover

 

Interactive_timeout = 120

Wait_timeout = 120

 

Skip-name-resolve

# Master-connect-retry = 10

Slave-skip-errors = 1396

 

# Master-host = 192.168.1.2

# Master-user = username

# Master-password = password

# Master-ports = 3306

 

 

Server-id = 1

 

Innodb_additional_mem_pool_size = 16 M

Innodb_buffer_pool_size = 512 M

Innodb_data_file_path = ibdata1: 256 M: autoextend

Innodb_file_io_threads = 4

Innodb_thread_concurrency = 8

Innodb_flush_log_at_trx_commit = 2

Innodb_log_buffer_size = 16 M

Innodb_log_file_size = 128 M

Innodb_log_files_in_group = 3

Innodb_max_dirty_pages_pct = 90

Innodb_lock_wait_timeout = 120

Innodb_file_per_table = 0

 

# Log-slow-queries =/home/mysql/log/slow. log

# Long_query_time = 10

 

[Mysqldump]

Quick

Max_allowed_packet = 32 M

 

Create related directories:

Mkdir-p/home/mysql/data/

Mkdir-p/home/mysql/log/

The command for creating a database is as follows:

/Home/mysql/bin/mysql_install_db \

-- Defaults-file =/home/mysql/my. cnf \

-- Basedir =/home/mysql \

-- Datadir =/home/mysql/data \

-- User = mysql

 

5) Configure MySQL as the System service

 

Cp/home/mysql/my. cnf/etc/

Cp/usr/local/web/mysql/share/mysql. server/etc/rc. d/init. d/mysql

Chmod + x/etc/rc. d/init. d/mysql

Chkconfig -- add mysql

 

6) Start MySQL

 

Service mysql start

 

7) modify the MySQL root Password

/Home/mysql/bin/mysqladmin-u root password 'mysql'

Change the mysql root Password to mysql.

 

8) Close MySQL

Service mysql stop

 

 

 

This article is from the "leom_lee" blog

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.