Linux下编译安装MySQL5.5

来源:互联网 发布:c语言中如何自定义类型 编辑:程序博客网 时间:2024/05/16 02:45

RHEL5 / OL5 / CentOS5 / SLES10 / SLES11 / openSuSE is OK!


yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel ssse2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gettext-devel libXpm-devel libtool perl-DBD-MySQL rpm-build gcc-c++ mysql mysql-devel readline-devel openssl-devel gmp-devel ncurses-devel gdbm-devel expat-devel libGL-devel libX11-devel tcl-devel tk-devel tix-devel sqlite-devel db4-devel

on Novell SuSE Linux

zypper install gcc gcc-c++ bison patch unzip mlocate flex wget automake autoconf gd cpp gettext readline-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers nss_ldap expat-devel libtool libtool-ltdl-devel bison libevent gpgme gpgme-devel perl-DBD-MySQL

[root@dbtest opt]# useradd mysql -s /sbin/nologin [root@dbtest opt]# mkdir -p /data/mysql /service




编译安装cmake

[root@dbtest opt]# tar -zxvf cmake-2.8.9.tar.gz [root@dbtest opt]# cd cmake-2.8.9[root@dbtest cmake-2.8.9]# ./configure [root@dbtest cmake-2.8.9]# make && make install


安装mysql

[root@dbtest opt]# tar -zxvf mysql-5.5.27.tar.gz [root@dbtest opt]# cd mysql-5.5.27[root@dbtest mysql-5.5.27]# cmake . -DCMAKE_INSTALL_PREFIX=/service/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/service/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=30307 -DCOMPILATION_COMMENT=Master_DB -DWITH_DEBUG=0[root@dbtest mysql-5.5.27]# make && make install
参数文件

[root@dbtest mysql-5.5.27]# cat /service/mysql/my.cnf [client]port            = 30307socket          = /data/mysql/mysql.sock[mysqld]port            = 30307socket          = /data/mysql/mysql.sockskip-external-lockingback_log = 500lower_case_table_names = 1skip-name-resolvemax_connections = 1024table_open_cache = 512binlog_cache_size = 1Mmax_heap_table_size = 300Mread_buffer_size = 10Mread_rnd_buffer_size = 16Msort_buffer_size = 8Mjoin_buffer_size=4Mthread_cache_size = 4thread_concurrency = 4query_cache_size = 200Mft_min_word_len = 4thread_stack = 192Ktmp_table_size = 200Mslow_query_loglong_query_time = 2slow_query_log_file = /data/mysql/slowsql.sqlkey_buffer_size = 32Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 200Mmyisam_repair_threads = 4myisam_recover# setup innodbinnodb_additional_mem_pool_size = 16Minnodb_buffer_pool_size = 2500Minnodb_data_file_path = ibdata1:10M:autoextendinnodb_write_io_threads = 4innodb_read_io_threads = 4innodb_thread_concurrency = 16innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 8Minnodb_log_file_size = 512Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120init_connect = 'SET autocommit=0'innodb-file-per-table = 1innodb-open-file = 500innodb_flush_method=O_DIRECTexpire_logs_days = 5federatedevent_scheduler = 1log-bin=binlog-masterbinlog_format=mixedserver-id       = 1[mysqldump]quickmax_allowed_packet = 16M[mysql]prompt=\\u@\\d \\r:\\m:\\s>no-auto-rehash[myisamchk]key_buffer_size = 128Msort_buffer_size = 128Mread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout[root@dbtest mysql-5.5.27]# 

--MySQL 5.6

gtid_mode=on
log_slave_updates=on
enforce_gtid_consistency=on

report_host=db02
master-info-repository=TABLE
relay-log-info-repository=TABLE



初始化数据字典,启动mysql

[root@dbtest ~]# cd /data/mysql/[root@dbtest mysql]# /service/mysql/scripts/mysql_install_db --defaults-file=/service/mysql/my.cnf --basedir=/service/mysql --datadir=/data/mysql --user=mysqlInstalling MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/service/mysql/bin/mysqladmin -u root password 'new-password'/service/mysql/bin/mysqladmin -u root -h 192.168.1.52 password 'new-password'Alternatively you can run:/service/mysql/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /service/mysql ; /service/mysql/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /service/mysql/mysql-test ; perl mysql-test-run.plPlease report any problems with the /service/mysql/scripts/mysqlbug script![root@dbtest mysql]# lltotal 1064-rw-rw---- 1 mysql mysql   27293 Dec 15 08:03 binlog-master.000001-rw-rw---- 1 mysql mysql 1037542 Dec 15 08:03 binlog-master.000002-rw-rw---- 1 mysql mysql      46 Dec 15 08:03 binlog-master.indexdrwx------ 2 mysql root     4096 Dec 15 08:03 mysqldrwx------ 2 mysql mysql    4096 Dec 15 08:03 performance_schemadrwx------ 2 mysql root     4096 Dec 15 08:03 test[root@dbtest mysql]# /service/mysql/bin/mysqld_safe --defaults-file=/service/mysql/my.cnf --basedir=/service/mysql --datadir=/data/mysql --user=mysql &[1] 3315[root@dbtest mysql]# 121215 08:03:41 mysqld_safe Logging to '/data/mysql/dbtest.err'.121215 08:03:41 mysqld_safe Starting mysqld daemon with databases from /data/mysql[root@dbtest mysql]# /service/mysql/bin/mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.5.27-log Master_DBCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

[root@dbtest zwc]# export PATH=$PATH:/service/mysql/bin[root@dbtest zwc]# mysqladmin -uroot password '123456'[root@dbtest zwc]# mysql -uroot -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)[root@dbtest zwc]# mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.5.27-log Master_DBCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> mysql> show grants;+----------------------------------------------------------------------------------------------------------------------------------------+| Grants for root@localhost                                                                                                              |+----------------------------------------------------------------------------------------------------------------------------------------+| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' WITH GRANT OPTION || GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                                           |+----------------------------------------------------------------------------------------------------------------------------------------+2 rows in set (0.00 sec)mysql> 


test

mysql> show engines;+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+| FEDERATED          | YES     | Federated MySQL storage engine                                 | NO           | NO   | NO         || MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         || MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         || BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         || CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         || InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        || ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         || MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         || PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+9 rows in set (0.00 sec)mysql> show variables like '%innodb_file_per_table%';+-----------------------+-------+| Variable_name         | Value |+-----------------------+-------+| innodb_file_per_table | ON    |+-----------------------+-------+1 row in set (0.00 sec)mysql> create table test.t_tab(id int primary key,`desc` varchar(100));Query OK, 0 rows affected (0.02 sec)mysql> system ls -l /data/mysql/testtotal 112-rw-rw---- 1 mysql mysql  8586 Dec 15 08:12 t_tab.frm-rw-rw---- 1 mysql mysql 98304 Dec 15 08:12 t_tab.ibdmysql> select @@version;+------------+| @@version  |+------------+| 5.5.27-log |+------------+1 row in set (0.00 sec)mysql> select @@version,now();+------------+---------------------+| @@version  | now()               |+------------+---------------------+| 5.5.27-log | 2012-12-15 08:12:37 |+------------+---------------------+1 row in set (0.00 sec)mysql> 





原创粉丝点击