`
dongbao100
  • 浏览: 34510 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

linux源码安装mysql

 
阅读更多

一、环境:

系统版本:CentOS5.5

MySQL版本:mysql-5.5.22

 

二、步骤:

1. 安装需要系统库相关库文件:

 

[root@localhost ~]# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*

 

2.需要的两个包

[root@localhost /]# cd /usr/local/src/

[root@localhost src]# ll

total 29332

-rw-r--r-- 1 root root  5517977 Jul 11 19:17 cmake-2.8.5.tar.gz

-rw-r--r-- 1 root root 24464834 Jul 11 19:17 mysql-5.5.22.tar.gz
 

1) 安装cmake

[root@localhost src]# tar zxvf cmake-2.8.5.tar.gz

[root@localhost src]# cd cmake-2.8.5

[root@localhost cmake-2.8.5]# ./bootstrap

…… ……

-- Build files have been written to: /usr/local/src/cmake-2.8.5

---------------------------------------------

CMake has bootstrapped.  Now run gmake.

[root@localhost cmake-2.8.5]# gmake
…… ……

[100%] Building CXX object Tests/CMakeLib/CMakeFiles/runcompilecommands.dir/run_compile_commands.cxx.o

Linking CXX executable runcompilecommands

[100%] Built target runcompilecommands

[root@localhost cmake-2.8.5]# gmake install

[root@localhost cmake-2.8.5]# cd ..
 

2)安装mysql

[root@localhost src]# groupadd mysql

[root@localhost src]# useradd -g mysql mysql

[root@localhost src]# tar zxvf mysql-5.5.22.tar.gz

[root@localhost src]# cd mysql-5.5.22

[root@localhost mysql-5.5.22]#
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql

…… ……

CMake Warning:

  Manually-specified variables were not used by the project:

    MYSQL_USER

    WITH_MEMORY_STORAGE_ENGINE

-- Build files have been written to: /usr/local/src/mysql-5.5.22

[root@localhost mysql-5.5.22]#make

…… ……

[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o

Linking CXX executable my_safe_process

[100%] Built target my_safe_process

[root@localhost mysql-5.5.22]#make install

…… ……

-- Installing: /usr/local/mysql/man/man1/mysql_find_rows.1

-- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1

-- Installing: /usr/local/mysql/man/man1/mysqlimport.1

-- Installing: /usr/local/mysql/man/man1/mysql_client_test.1

-- Installing: /usr/local/mysql/man/man8/mysqld.8

 

[root@localhost mysql-5.5.22]# chmod +w /usr/local/mysql/

[root@localhost mysql-5.5.22]# chown -R mysql:mysql /usr/local/mysql/

[root@localhost mysql-5.5.22]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

[root@localhost mysql-5.5.22]# mkdir -p /var/mysql

[root@localhost mysql-5.5.22]# mkdir -p /var/mysql/data/

[root@localhost mysql-5.5.22]# mkdir -p /var/mysql/log/

[root@localhost mysql-5.5.22]# chown -R mysql:mysql /var/mysql/

[root@localhost mysql-5.5.22]# cd support-files/

[root@localhost support-files]# cp my-medium.cnf /etc/my.cnf

[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
 

 

初始化安装。

 

[root@localhost support-files]# /usr/local/mysql/scripts/mysql_install_db \

--defaults-file=/etc/my.cnf \

--basedir=/usr/local/mysql \

--datadir=/var/mysql/data \

--user=mysql

…… ……

You can start the MySQL daemon with:

cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!

[root@localhost support-files]# chmod +x /etc/init.d/mysql

[root@localhost support-files]# vi /etc/init.d/mysql

 basedir=/usr/local/mysql

 datadir=/var/mysql/data

[root@localhost support-files]#chkconfig --add mysql

[root@localhost support-files]#chkconfig --level 345 mysql on

[root@localhost support-files]# cd /usr/local/mysql

[root@localhost mysql]# service mysql start

Starting MySQL.. SUCCESS!

[root@localhost mysql]# mysql

-bash: mysql: command not found

[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.22 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.01 sec)

mysql> exit

Bye

[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin

[root@localhost mysql]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.5.22 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> grant all privileges on *.* to root@'%' identified by 'joy' with grant option;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye
 

 

//设置停止防火墙

[root@localhost mysql]# /etc/init.d/iptables stop;

Flushing firewall rules: [  OK  ]

Setting chains to policy ACCEPT: filter [  OK  ]

Unloading iptables modules: [  OK  ]
 或添加3306端口允许访问
vi /etc/sysconfig/iptables
#添加3306端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics