centos cmake 安装 mysql-5.5.16 附配置文件

mysql从5.5之后源码安装需要使用cmake:

==================================================

To install MySQL from source, your system must have the following tools, regardless of installation method:

  • CMake, which is used as the build framework on all platforms.CMake can be downloaded fromhttp://www.cmake.org.

  • A good make program. Although some platforms come with their ownmake implementations, it is highly recommended that you use GNUmake 3.75 or newer. It may already be available on your system asgmake. GNUmake is available fromhttp://www.gnu.org/software/make/.

  • A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 10 or later, Visual Studio 2008 or later, and many current vendor-supplied compilers are known to work.

  • Perl is needed if you intend to run test scripts. Most Unix-like systems include Perl. On Windows, you can use a version such as ActiveState Perl.

=======================================

yum 安装 gcc,gcc-c++,cmake,bison(GNU),使用 centos6.0 自带的perl和openssl

添加mysql组和mysql用户

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

将mysql和data文件安装到不同的物理磁盘上

cmake -DCMAKE_INSTALL_PREFIX=/opt/soft/mysql \
-DMYSQL_DATADIR=/home/soft/mysql/data \
-DMYSQL_UNIX_ADDR=/opt/soft/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DWITH_SSL=yes

报错:

  -- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
              CMake Error at cmake/readline.cmake:82 (MESSAGE):
                   Curses library not found.  Please install appropriate package,

 

                   remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu , package name is libncurses5-dev ,

                   on RedHat and derivates it is ncurses-devel.
              Call Stack (most recent call first):
              cmake/readline.cmake:126 (FIND_CURSES)
              cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
              CMakeLists.txt:256 (MYSQL_CHECK_READLINE)


               -- Configuring incomplete, errors occurred!

=======================

没有安装 ncurses-devel

yum安装之后 还是报错,找运维高手才知道 cmake会产生CMakeCache.txt文件,每次cmake之前需要删除它....

ok,一切正常

echo $?

输出结果为0

make -j 4

make install -j 4

安装成功(因为是在4核cpu的机器上安装所以使用了 -j 4)


mv -f /opt/soft/mysql/data//home/soft/mysql/

mkdir /opt/soft/mysql/config

mkdir /opt/soft/mysql/binlog

mkdir /opt/soft/mysql/log

chown mysql:mysql /home/soft/mysql -R

chown mysql:mysql /opt/soft/mysql/ -R


初始化数据库

cd /opt/soft/mysql/

/opt/soft/mysql/scripts/mysql_install_db  --defaults-file=/opt/soft/mysql/config/my.cnf  --basedir=/opt/soft/mysql  --datadir=/home/soft/mysql/data  --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h c60h.localdomain password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!


===============================

之所以要安装mysql5.5.16是想将Percona-5.5.16中的xtraDB安装到mysql中,替换了storage中的innobase,结果make步骤中报错,只能是单独安装Percona了.

=================================

启动

/opt/soft/mysql/bin/mysqld_safe --defaults-file=/opt/soft/mysql/config/my.cnf --user=mysql &
[1] 25812
# 111031 13:18:55 mysqld_safe Logging to '/home/soft/mysql/data/c60h.localdomain.err'.
111031 13:18:55 mysqld_safe Starting mysqld daemon with databases from /home/soft/mysql/data
^C
# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:50341               0.0.0.0:*                   LISTEN      1409/rpc.statd      
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      26217/mysqld        
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1340/rpcbind        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1619/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1121/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1695/master         
tcp        0     52 192.168.161.141:22          192.168.161.1:54674         ESTABLISHED 1820/sshd: admin [p
tcp        0      0 :::42759                    :::*                        LISTEN      1409/rpc.statd      
tcp        0      0 :::111                      :::*                        LISTEN      1340/rpcbind        
tcp        0      0 :::22                       :::*                        LISTEN      1619/sshd           

tcp        0      0 ::1:631                     :::*                        LISTEN      1121/cupsd        

===============================

配置mysql用户
 /opt/soft/mysql/bin/mysqladmin -u root password 123456

=================================

/opt/soft/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

不用密码登陆不进去咧

=================================

/opt/soft/mysql/bin/mysql -p123456

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.16-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user,password from user;
+------------------+------+-------------------------------------------+
| host             | user | password                                  |
+------------------+------+-------------------------------------------+
| localhost        | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| c60h.localdomain | root |                                           |
| 127.0.0.1        | root |                                           |
| ::1              | root |                                           |
| localhost        |      |                                           |
| c60h.localdomain |      |                                           |
+------------------+------+-------------------------------------------+
6 rows in set (0.00 sec)

mysql> delete from user where LENGTH(password)<10;
Query OK, 5 rows affected (0.00 sec)

mysql> select host,user,password from user;       
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> grant all on *.* to 'admin'@'192.168.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;
+-------+-----------+-------------------------------------------+
| user  | host      | password                                  |
+-------+-----------+-------------------------------------------+
| root  | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| admin | 192.168.% | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-------+-----------+-------------------------------------------+
2 rows in set (0.00 sec)

===================

root用户只能本机登陆

admin 只能局域网登陆

==============================

开启 3306 端口

vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

service iptables restart

重启 iptables 生效

========================

配置文件

cat config/my.cnf
[client]
#password                       = your_password
port                            = 3306
socket                          = /opt/soft/mysql/mysql.sock
default-character-set           = utf8

[mysql]
default-character-set           = utf8

[mysqld]
character-set-server            = utf8
datadir                         = /home/soft/mysql/data
tmpdir                          = /dev/shm
port                            = 3306
socket                          = /opt/soft/mysql/mysql.sock
pid-file                        = /opt/soft/mysql/601.localdomain.pid
skip-external-locking
key_buffer_size                 = 16K
max_allowed_packet              = 1M
table_open_cache                = 4
sort_buffer_size                = 64K
read_buffer_size                = 256K
read_rnd_buffer_size            = 256K
net_buffer_length               = 2K
thread_stack                    = 128K

default-storage-engine          = innodb
innodb_buffer_pool_size         = 128M
innodb_data_home_dir            = /home/soft/mysql/data
innodb_data_file_path           = ibdata1:10M:autoextend
innodb_log_group_home_dir       = /opt/soft/mysql/log
innodb_log_file_size            = 512M
innodb_log_files_in_group       = 3
innodb_lock_wait_timeout        = 60
innodb_flush_log_at_trx_commit  = 2

#read_io_threads+writ_io_threads

innodb_thread_concurrency=16

#Physical Harddisk X2
innodb_read_io_threads=8
innodb_write_io_threads=8


innodb_purge_batch_size=128

innodb_purge_threads=1


#skip-networking
server-id                       = 601

log-slave-updates
log-bin                         = /opt/soft/mysql/binlog/mysql-bin
relay-log                       = /opt/soft/mysql/binlog/mysql-relay-bin
#binlog_format=mixed

# Causes updates to non-transactional engines using statement format to be
# written directly to binary log. Before using this option make sure that
# there are no dependencies between transactional and non-transactional
# tables such as in the statement INSERT INTO t_myisam SELECT * FROM
# t_innodb; otherwise, slaves may diverge from the master.
#binlog_direct_non_transactional_updates=TRUE

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet              = 16M

[mysqladmin]
#socket                         = /home/mysql/data/mysql.sock

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size                 = 8M
sort_buffer_size                = 8M

[mysqlhotcopy]
interactive-timeout

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值