CentOS 5.4 x86_64 compile and install MySQL full notes

Source: Internet
Author: User
Tags mysql code

MySQL compilation and Installation notes
The premise is that your Linux system should build the GCC compiling environment.
If CentOS is used, you can:
Yum-y install gcc
Yum-y install gcc-c ++
Add MySQL user groups and users
Grounadd mysql
Useradd-g mysql
MySQL compilation and installation of dependent software packages:
Cd/tmp
Wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz
Tar-zvxf ncurses-5.7.tar.gz
Cd ncurses-5.7
./Configure -- prefix =/usr -- with-shared -- without-debug
Make
Make install

Modify the maximum number of connections of MySQL, unbind the original MySQL code, and go to the SQL directory to modify mysqld. cc and find the following line:
{"Max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed. ", (gptr *) & max_connections, (gptr *) & max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 16384, 0 },
Change it:
{"Max_connections", OPT_MAX_CONNECTIONS, "The number of simultaneous clients allowed. ", (gptr *) & max_connections, (gptr *) & max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0 },
Compile and install MySQL:
Cd/tmp
Wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.2-m2.tar.gz
Tar-zvxf mysql-5.5.2-m2.tar.gz
Cd mysql-5.5.2-m2
CFLAGS = "-O3" CXX = gcc CXXFLAGS = "-O3-felide-constructors-fno-exceptions-fno-rtti-fomit-frame-pointer-ffixed-ebp"
. /Configure -- prefix =/usr/local/mysql -- enable-character er -- with-charset = utf8 -- with-collation = utf8_general_ci -- with-extra-charsets = all -- enable-thread- safe-client -- with-big-tables -- with-readline -- with-ssl -- with-embedded-server -- enable-local-infile -- with-client-ldflags =-all-static -- with-mysqld-ldflags =-all-static -- with-plugins = partition, innobase, myisammrg
Make
Make install
When installing mysql on CentOS, it may take a while (mysql-test ).
After the installation is complete, modify the directory permission:
Chmod + w/usr/local/mysql
Chown-R mysql: mysql/usr/local/mysql
Create some necessary directories:
Mkdir-p/usr/local/mysql/data
Mkdir-p/usr/local/mysql/binlog
Mkdir-p/usr/local/mysql/relaylog
Chown-R mysql: mysql/usr/local/mysql
Create a data table using the identity of the mysql user account (www.bkjia.com can also be said to initialize the mysql database ):
/Usr/local/mysql/bin/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql
Create a MySQL configuration file. The configuration file name is usually my. cnf:
Vi/usr/local/mysql/my. cnf
Enter and save the following content:
[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 =/usr/local/mysql
Datadir =/usr/local/mysql/data
Log-error =/usr/local/mysql/mysql_error.log
Pid-file =/usr/local/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 =/usr/local/mysql/binlog
Binlog_cache_size = 4 M
Binlog_format = MIXED
Max_binlog_cache_size = 8 M
Max_binlog_size = 1G
Relay-log-index =/usr/local/mysql/relaylog
Relay-log-info-file =/usr/local/mysql/relaylog
Relay-log =/usr/local/mysql/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 =/usr/local/mysql/slow. log
# Long_query_time = 10
[Mysqldump]
Quick
Max_allowed_packet = 32 M

Create a shell script for MySQL database management:
Vi/usr/local/mysql
Enter the following content and save it (here the user name root and password 123456 will be created in the Next Step ):
#! /Bin/sh
Mysql_port = 3306
Mysql_username = "root"
Mysql_password = "123456"
Function_start_mysql ()
{
Printf "Starting MySQL... \ n"
/Bin/sh/usr/local/mysql/bin/mysqld_safe -- defaults-file =/usr/local/mysql/my. cnf 2> & 1>/dev/null &
}
Function_stop_mysql ()
{
Printf "Stoping MySQL... \ n"
/Usr/local/mysql/bin/mysqladmin-u $ {mysql_username}-p $ {mysql_password}-S/tmp/mysql. sock shutdown
}
Function_restart_mysql ()
{
Printf "Restarting MySQL... \ n"
Function_stop_mysql
Sleep 5
Function_start_mysql
}
Function_kill_mysql ()
{
Kill-9 $ (ps-ef & #124; grep 'bin/mysqld_safe '& #124; grep $ {mysql_port} & #124; awk' {printf $2 }')
Kill-9 $ (ps-ef & #124; grep 'libexec/mysqld' & #124; grep $ {mysql_port} & #124; awk '{printf $2 }')
}
If ["$1" = "start"]; then
Function_start_mysql
Elif ["$1" = "stop"]; then
Function_stop_mysql
Elif ["$1" = "restart"]; then
Function_restart_mysql
Elif ["$1" = "kill"]; then
Function_kill_mysql
Else
Printf "Usage:/usr/local/mysql {start & #124; stop & #124; restart & #124; kill} \ n"
Fi
Grant the shell script executable permission to the MySQL database:
Chmod + x/usr/local/mysql
Start MySQL:
/Usr/local/mysql start
Log on to and manage the MySQL server through the command line (press Enter when prompted to enter the password ):
/Usr/local/mysql/bin/mysql-u root-p-S/tmp/mysql. sock
Enter the following SQL statement to create a user (root) and password (123456) with root permissions ):
Grant all privileges on *. * TO 'root' @ 'localhost' identified by '123 ';
Grant all privileges on *. * TO 'root' @ '1970. 0.0.1 'identified by '123 ';
Stop MySQL command:
/Usr/local/mysql stop

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.