cmake编译安装mysql5.5
admin
2023-05-20 12:02:53
0次

                            CMAKE方式编译安装Mysql5.5

1、源码cmake方式编译安装MySQL5.5.32

安装前先安装:

yum install ncurses-devel -y


1.1 下载Mysql和cmake安装包:

wget http://wwwNaNake.org/files/v2.8/cmake-2.8.8.tar.gz


1.2 查看系统环境

cat /etc/redhat-release

uname -r

uname -m

1.3 安装cmake包

tar zxf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

gmake

gmake install

cd ../

1.4 开始安装mysql

1.4.1 创建用户和组

groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql

yum install ncurses-devel -y


1.4.2 解压编译MySQL

tar zxf mysql-5.5.32.tar.gz

cd mysql-5.5.32


cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data\

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock\

-DDEFAULT_CHARSET=gbk\

-DDEFAULT_COLLATION=gbk_chinese_ci\

-DENABLED_LOCAL_INFILE=ON\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\

-DWITHOUT_PARTITION_STORAGE_ENGINE=1


make


make install

ln -s /application/mysql-5.5.32/ /application/mysql

如果上述操作未出现错误,则MySQL软件的安装就算成功了。


1.4.3 初始化配置MySQL

1.查看默认模板配置文件

[root@Mysqlmysql-5.5.32]# ll support-files/my*.cnf

-rw-r--r--1 root root  4759 Apr 25 18:19support-files/my-huge.cnf

-rw-r--r--1 root root 19809 Apr 25 18:19 support-files/my-innodb-heavy-4G.cnf

-rw-r--r--1 root root  4733 Apr 25 18:19support-files/my-large.cnf

-rw-r--r--1 root root  4744 Apr 25 18:19support-files/my-medium.cnf

-rw-r--r--1 root root  2908 Apr 25 18:19support-files/my-small.cnf

2.选择配置文件

/bin/cpsupport-files/my-small.cnf /etc/my.cnf

测试环境选小的,生产环境可以根据硬件选择support-files/my-innodb-heavy-4G.cnf


3.配置环境变量

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

tail -1 /etc/profile

source /etc/profile

echo $PATH


4.初始化数据文件(容易出错的步骤)

#建立mysql数据文件目录

mkdir -p /application/mysql/data

#授权mysql用户访问mysql的安装目录

chown -R mysql.mysql /application/mysql/*

chmod -R 1777 /tmp

#初始化数据库文件(如果重新初始化数据库文件,必须先执行:rm -fr /application/mysql/data/*)

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql--datadir=/application/mysql/data --user=mysql    

特别提示:

a.如果用mysql 5.0,5.1省略指定datadir会出错。


5.设置常规方式启动关闭脚本

cd /application/tools/mysql-5.5.32/

#拷贝mysql启动脚本到/etc/init.d/下

cp support-files/mysql.server /etc/init.d/mysqld

#授权700权限,即脚本可执行

chmod 700 /etc/init.d/mysqld

/etc/init.d/mysqldstart

chkconfig mysqld on

chkconfig --list mysqld


6.登录mysql


7.简单优化mysql

a.删除test库:

mysql>show databases;

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

|Database           |

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

|information_schema |

|mysql              |

|performance_schema |

|test               |

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

4 rowsin set (0.03 sec)


mysql>drop database test;

Query OK, 0 rows affected (0.04 sec)


mysql>show databases;

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

|Database           |

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

|information_schema |

|mysql              |

|performance_schema |

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

3 rowsin set (0.00 sec)


b.清除并修改管理员用户

mysql>select user,host from mysql.user;  

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

| user| host      |

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

| root| 127.0.0.1 |

| root| ::1       |

|      | Mysql     |

| root| Mysql     |

|      | localhost |

| root| localhost |

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

6 rowsin set (0.00 sec)


mysql>delete from mysql.user;

QueryOK, 6 rows affected (0.07 sec)


mysql>select user,host from mysql.user;

Emptyset (0.00 sec)

mysql>grant all privileges on *.* to system@'localhost' identified by '1234' withgrant option;

QueryOK, 0 rows affected (0.00 sec)

mysql>flush privileges;

QueryOK, 0 rows affected (0.00 sec)

mysql>grant all privileges on *.* to system@'127.0.0.1' identified by '1234' withgrant option;        

QueryOK, 0 rows affected (0.00 sec)

mysql>select user,host from mysql.user;

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

|user   | host      |

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

|system | 127.0.0.1 |

|system | localhost |

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

2 rowsin set (0.00 sec)


操作过程:

[root@mysqltools]# cat /etc/redhat-release

CentOSrelease 6.4 (Final)

[root@mysqltools]# uname -r

2.6.32-358.el6.x86_64

[root@mysqltools]# uname -m

x86_64


[root@mysqltools]# tar zxf cmake-2.8.8.tar.gz

[root@mysqltools]# cd cmake-2.8.8

[root@mysqlcmake-2.8.8]# ./configure

CMakehas bootstrapped.  Now run gmake.

[root@Mysqlcmake-2.8.8]# gmake

[root@Mysqlcmake-2.8.8]# gmake install

[root@Mysqlapplication]# groupadd mysql

[root@Mysqlapplication]# useradd mysql -s /sbin/nologin -M -g mysql

[root@Mysqltools]# tar zxf mysql-5.5.32.tar.gz

[root@Mysqltools]# cd mysql-5.5.32

[root@Mysqlmysql-5.5.32]# cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

cmake. -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data\

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock\

-DDEFAULT_CHARSET=gbk\

-DDEFAULT_COLLATION=gbk_chinese_ci\

-DENABLED_LOCAL_INFILE=ON\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\

-DWITHOUT_PARTITION_STORAGE_ENGINE=1


#Build files have been written to: /application/tools/mysql-5.5.32   如果显示这个表示cmake成功


[root@Mysqlmysql-5.5.32]# make

[root@Mysqlmysql-5.5.32]# make install

[root@Mysqlmysql-5.5.32]# ln -s /application/mysql-5.5.32//application/mysql

[root@Mysqlmysql-5.5.32]# ll support-files/my*.cnf

-rw-r--r--1 root root  4759 Apr 25 18:19support-files/my-huge.cnf

-rw-r--r--1 root root 19809 Apr 25 18:19 support-files/my-innodb-heavy-4G.cnf

-rw-r--r--1 root root  4733 Apr 25 18:19support-files/my-large.cnf

-rw-r--r--1 root root  4744 Apr 25 18:19support-files/my-medium.cnf

-rw-r--r--1 root root  2908 Apr 25 18:19support-files/my-small.cnf

[root@Mysqlmysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnf

[root@Mysqlmysql-5.5.32]# echo 'export PATH=/application/mysql/bin:$PATH'>>/etc/profile

[root@Mysqlmysql-5.5.32]# tail -1 /etc/profile

exportPATH=/application/mysql/bin:$PATH

[root@Mysqlmysql-5.5.32]# source /etc/profile

[root@Mysqlmysql-5.5.32]# echo $PATH

/application/mysql/bin:/application/mysql/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[root@Mysqlmysql-5.5.32]# mkdir -p /application/mysql/data

[root@Mysqlmysql-5.5.32]# chown -R mysql.mysql /application/mysql/*

[root@Mysqlmysql-5.5.32]# chmod -R 1777 /tmp

[root@Mysqlmysql-5.5.32]# /application/mysql/scripts/mysql_install_db--basedir=/application/mysql --datadir=/application/mysql/data--user=mysql  

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

[root@Mysqlmysql-5.5.32]# chmod 700 /etc/init.d/mysqld

[root@Mysqlmysql-5.5.32]# chkconfig mysqld on

[root@Mysqlmysql-5.5.32]# chkconfig --list mysqld

mysqld          0:off   1:off  2:on    3:on    4:on   5:on    6:off

root@Mysqlmysql-5.5.32]# mysql

Welcometo the MySQL monitor.  Commands end with; or \g.

YourMySQL connection id is 2

Serverversion: 5.5.32 Source distribution


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


Oracleis 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>


简单优化mysql

a.删除test库:

mysql>show databases;

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

|Database           |

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

|information_schema |

|mysql              |

|performance_schema |

|test               |

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

4 rowsin set (0.03 sec)


mysql>drop database test;

QueryOK, 0 rows affected (0.04 sec)


mysql>show databases;

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

|Database           |

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

|information_schema |

|mysql              |

|performance_schema |

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

3 rowsin set (0.00 sec)


b.清除并修改管理员用户

mysql>select user,host from mysql.user;  

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

| user| host      |

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

| root| 127.0.0.1 |

| root| ::1       |

|      | Mysql     |

| root| Mysql     |

|      | localhost |

| root| localhost |

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

6 rowsin set (0.00 sec)


mysql>delete from mysql.user;

Query OK, 6 rows affected (0.07 sec)


mysql>select user,host from mysql.user;

Emptyset (0.00 sec)

mysql>grant all privileges on *.* to system@'localhost' identified by '1234' withgrant option;

Query OK, 0 rows affected (0.00 sec)

mysql>flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql>grant all privileges on *.* to system@'127.0.0.1' identified by '1234' withgrant option;        

Query OK, 0 rows affected (0.00 sec)

mysql>select user,host from mysql.user;

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

|user   | host      |

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

|system | 127.0.0.1 |

|system | localhost |

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

2 rowsin set (0.00


1、CMAKE安装Mysql时遇到的问题:

--Check size of wint_t - done

--Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMakeError at cmake/readlineNaNake:83 (MESSAGE):

 Curses library not found.  Please install appropriate package,

     remove CMakeCache.txt and rerun cmake.OnDebian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it isncurses-devel.

CallStack (most recent call first):

 cmake/readlineNaNake:127 (FIND_CURSES)

 cmake/readlineNaNake:217(MYSQL_USE_BUNDLED_LIBEDIT)

 CMakeLists.txt:269 (MYSQL_CHECK_READLINE)

--Configuring incomplete, errors occurred!


解决方法:

rm CMakeCache.txt

yum install ncurses-devel -y

然后再cmake



相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...