mysql 5.5 cmake 安装

本文提供了一步一步的指南,详细介绍了如何使用 cmake 进行 MySQL 5.5 的编译、配置、初始化数据库及设置密码的过程。从下载、安装依赖到最终启动 MySQL 服务,涵盖了整个流程。
#mysql5.5 开始必须使用cmake编译
[root@166087 cmake-2.8.5]# wget wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
[root@166087 cmake-2.8.5]# tar xzvf cmake-2.8.5.tar.gz
[root@166087 cmake-2.8.5]# cd cmake-2.8.5
[root@166087 cmake-2.8.5]# ./bootstrap
[root@166087 cmake-2.8.5]# make && make install
#cmake 需要安装gcc
[root@166087 cmake-2.8.5]# yum -y install gcc*
[root@166087 cmake-2.8.5]# ./bootstrap
[root@166087 cmake-2.8.5]# make && make install

#下载mysql
[root@166087 mysql]# wget http://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.32.tar.gz
[root@166087 mysql]# tar xf mysql-5.5.32.tar.gz

#添加mysql用户
[root@166087 mysql]# useradd -M mysql -s /sbin/nologin

#字符集
[root@166087 mysql]# yum -y install ncurses-devel*

#cmake编译参数
/usr/local/bin/cmake  -DCMAKE_INSTALL_PREFIX=/application/mysql5.5 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_USER=mysql \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1

 #cmake 配置参数对比
 http://www.blogjava.net/kelly859/archive/2012/09/04/387005.html

 #如果cmake失败,重新cmake,必须清除一下
 make clean
 rm CMakeCache.txt
 
#编译mysql
[root@166087 mysql-5.5.32]# make && make install

#映射路径
[root@166087 mysql-5.5.32]# ln -s /application/mysql5.5  /application/mysql

#拷贝配置文件
[root@166087 mysql]# mkdir conf
[root@166087 mysql]# cp support-files/my-large.cnf conf/my.cnf

#初始化数据库
./scripts/mysql_install_db \
--defaults-file=/application/mysql/conf/my.cnf \
--basedir=/application/mysql \
--datadir=/application/mysql/data/ \
--user=mysql


[root@166087 mysql]# ./scripts/mysql_install_db \
> --defaults-file=/application/mysql/conf/my.cnf \
> --basedir=/application/mysql \
> --datadir=/application/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:

/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h 166087.sys.ipv4.io password 'new-password'

Alternatively you can run:
/application/mysql/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 /application/mysql ; /application/mysql/bin/mysqld_safe &

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

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

#拷贝启动脚本
[root@166087 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@166087 mysql]# chmod +x /etc/init.d/mysqld

#启动
[root@166087 ~]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!

[root@166087 ~]# netstat -lntup | grep mysqld
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      15478/mysqld

[root@166087 ~]# netstat -lntup | grep mysqld
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      15478/mysqld

[root@166087 ~]# ps -ef | grep mysql
root     15387     1  0 03:43 pts/0    00:00:00 /bin/sh /application/mysql5.5/bin/mysqld_safe --datadir=/application/mysql5.5/data --pid-file=/application/mysql5.5/data/166087.sys.ipv4.io.pid
mysql    15478 15387  0 03:43 pts/0    00:00:00 /application/mysql5.5/bin/mysqld --basedir=/application/mysql5.5 --datadir=/application/mysql5.5/data --plugin-dir=/application/mysql5.5/lib/plugin --user=mysql --log-error=/application/mysql5.5/data/166087.sys.ipv4.io.err --pid-file=/application/mysql5.5/data/166087.sys.ipv4.io.pid


#设置root密码
[root@166087 ~]# /application/mysql/bin/mysqladmin -u root -p password 123456

#登录
[root@166087 ~]# /application/mysql/bin/mysql -uroot -hlocalhost -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 Source distribution

Copyright (c) 2000, 2013, 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)


转载于:https://my.oschina.net/web256/blog/521810

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值