Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MySQL in CentOS

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how to install MySQL in CentOS, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

1. Software acquisition

A stable version of mysql5.1.58 is available from the official website. Select souce code to install the package.

If the host is directly connected to the public network, the software package can be obtained directly on the host by using the following methods:

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

two。 Installation method

1) decompress the package

Tar xvf mysql-5.1.58.tar.gz

2) configure mysql users

Useradd-d / home/mysql mysql

Edit the. bash_profile of the 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) configure, compile, compile and install

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

-- with-unix-socket-path=/home/mysql/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-assembler\

-- enable-local-infile\

-- enable-thread-safe-client

Make

Make install

4) create a MySQL

Edit the my.cnf file before creating the database. The my.cnf file is placed in the MySQL installation directory (/ home/). 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/mysql.pid

Open_files_limit = 10240

Back_log = 600,

Max_connections = 5000

Max_connect_errors = 6000

Table_cache = 614

External-locking = FALSE

Max_allowed_packet = 32m

Sort_buffer_size = 1m

Join_buffer_size = 1m

Thread_cache_size = 300

# thread_concurrency = 8

Query_cache_size = 512m

Query_cache_limit = 2m

Query_cache_min_res_unit = 2k

Default-storage-engine = MyISAM

Thread_stack = 19K

Transaction_isolation = READ-COMMITTED

Tmp_table_size = 246m

Max_heap_table_size = 246m

Long_query_time = 3

Log-slave-updates

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

Binlog_cache_size = 4m

Binlog_format = MIXED

Max_binlog_cache_size = 8m

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 = 256m

Read_buffer_size = 1m

Read_rnd_buffer_size = 16m

Bulk_insert_buffer_size = 64m

Myisam_sort_buffer_size = 128m

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 = 1032, 1062, 126, 1114, 1146, 1048, 1396.

# master-host = 192.168.1.2

# master-user = username

# master-password = password

# master-port = 3306

Server-id = 1

Innodb_additional_mem_pool_size = 16m

Innodb_buffer_pool_size = 512m

Innodb_data_file_path = ibdata1:256M:autoextend

Innodb_file_io_threads = 4

Innodb_thread_concurrency = 8

Innodb_flush_log_at_trx_commit = 2

Innodb_log_buffer_size = 16m

Innodb_log_file_size = 128m

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 = 32m

Create related directories:

Mkdir-p / home/mysql/data/

Mkdir-p / home/mysql/log/

The command to create the 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 system service

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

Cp / usr/local/web/mysql/share/mysql/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 MySQL root password

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

Change the password of mysql root to mysql

8) MySQL is off

Service mysql stop

The above is how to install MySQL in CentOS. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report