博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cmake安装MySQL
阅读量:7091 次
发布时间:2019-06-28

本文共 5672 字,大约阅读时间需要 18 分钟。

发现一个网址整理的挺好,请各位参考:

也可以参考我的另一篇文章,整合到lamp中了:

1、编辑脚本cmake_mysql_install.sh,输入以下内容:

#!/bin/bash#下载并安装makeyum -y install gcc   #排除错误:configure: error: in `/usr/local/src/make-4.1':   configure: error: no acceptable C compiler found in $PATHcd /usr/local/src/wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gztar zxvf make-4.1.tar.gzcd make-4.1./configuremake && make install#下载并安装bisoncd /usr/local/src/          wget http://alpha.gnu.org/gnu/bison/bison-2.7.91.tar.gz tar zxvf bison-2.7.91.tar.gzcd bison-2.7.91./configuremake && make install#安装gcc-c++yum -y install gcc-c++#for ubuntu:#apt-get install g++#下载并解压camkecd /usr/local/src/wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gztar zxvf cmake-3.2.2.tar.gzcd cmake-3.2.2./bootstrapgmake && gmake install#or #make && make install#下载安装ncursescd /usr/local/src/wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gztar -zxvf ncurses-5.9.tar.gzcd ncurses-5.9./configuremake && make install#安装mysql#首先,创建mysql用户、组groupadd mysqluseradd -g mysql mysql -s /usr/sbin/nologinmkdir /usr/local/mysql        # 创建目录mkdir /usr/local/mysql/data   # 数据仓库目录cd /usr/local/src/ wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz #解压安装tar zxvf mysql-5.6.24.tar.gzcd mysql-5.6.24cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql              #安装路径make && make install cd /usr/local/mysqlscripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql   #初始化mysql数据库 # cp support-files/my-medium.cnf /usr/local/mysql/my.cnf                                             #copy配置文件cp support-files/my-default.cnf /usr/local/mysql/my.cnf chown -R mysql:mysql /usr/local/mysql                                                              #更改权限
View Code

安装MySQL可选项:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc                  \   #my.cnf路径-DWITH_MYISAM_STORAGE_ENGINE=1     \   #支持MyIASM引擎-DWITH_INNOBASE_STORAGE_ENGINE=1   \   #支持InnoDB引擎-DWITH_MEMORY_STORAGE_ENGINE=1     \   #支持Memory引擎-DWITH_READLINE=1                  \   #快捷键功能(我没用过)-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \   #连接数据库socket路径-DMYSQL_TCP_PORT=3306             \   #端口-DENABLED_LOCAL_INFILE=1          \   #允许从本地导入数据-DWITH_PARTITION_STORAGE_ENGINE=1 \   #安装支持数据库分区-DEXTRA_CHARSETS=all              \   #安装所有的字符集-DDEFAULT_CHARSET=utf8            \   #默认字符-DDEFAULT_COLLATION=utf8_general_ci

 2、# nano /usr/local/mysql/my.cnf ,添加以下内容(或者换成vim工具):

[mysqld]basedir = /usr/local/mysqldatadir = /usr/local/mysql/datalog-error = /usr/local/mysql/mysql_error.logpid-file = /usr/local/mysql/mysql.piduser = mysqltmpdir = /tmp
View Code

注意:对于nano,要保存所做的修改,按下Ctrl+O;退出,按下Ctrl+X。若退出前没有保存所做的修改,它会提示你是否要保存。如果不要,请按N,反之,则按Y。然后它会让你确认要保存的文件名,确认或修改后按Enter即可。

如果你没有修改好而不小心按了保存键,您可以在请求确认文件名时按Ctrl+C来取消。

3、启动MySQL:en

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# /etc/init.d/mysqld start

 4、进入MySQL命令行;

$ mysqlbash: mysql: command not found $ which mysql/usr/bin/which: no mysql in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/lot/bin:/usr/local/python27/bin:/home/lot/bin)[lot@bogon ~]$ whereis mysqlmysql: /usr/lib64/mysql /usr/local/mysql /usr/share/mysql# ln -s /usr/local/mysql/bin/mysql /usr/bin

  # mysql

  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock # service mysqld restart

5、好了,

[root@bogon bin]# service mysqld restart ERROR! MySQL server PID file could not be found!Starting MySQL... SUCCESS! [root@bogon bin]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.24 Source distributionCopyright (c) 2000, 2015, 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> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || test               |+--------------------+4 rows in set (0.04 sec)
View Code

6、遇到的一些错误整理:

6-1、安装 bison:

checking for GNU M4 that supports accurate traces... configure: error: no acceptable m4 could be found in $PATH.GNU M4 1.4.6 or later is required; 1.4.16 or newer is recommended.GNU M4 1.4.15 uses a buggy replacement strstr on some systems.Glibc 2.9 - 2.12 and GNU M4 1.4.11 - 1.4.15 have another strstr bug.
View Code

解决方法(参考网址:)

cd /usr/local/srcwget -O m4-1.4.9.tar.gz http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gztar -zvxf m4-1.4.9.tar.gzcd m4-1.4.9./configuremake && make install
View Code

 6-2、启动MySQL:

* MySQL server PID file could not be found!Starting MySQL.. * The server quit without updating PID file (/usr/local/mysql/mysql.pid).

解决方法参考网址: http://www.jb51.net/article/48625.htm

个人解决方法:删除安装后的MySQL目录及下面的所有文件,重新编译安装。

 6-3、权限不够(参考:):

[root@vn /]# /etc/init.d/mysqld start-bash: /etc/init.d/mysqld: 权限不够[root@vn /]# service mysqld startenv: /etc/init.d/mysqld: 权限不够[root@vn /]# chmod a+wrx /etc/init.d/mysqld            以root执行此命令[root@vn /]# service mysqld startStarting MySQL...                                          [确定]

7、其他安装参考网址:

使用cmake安装mysql5.5.13:

linux cmake 安装mysql5.5.11,以及更高版本:

Linux下的Nano命令:

CMAKE安装MYSQL 5.6.10:

LINUX下使用CMAKE安装MYSQL(源码编译):

问题处理参考网址:

解决bash: mysql: command not found 的方法:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock':

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2):

转载于:https://www.cnblogs.com/chinas/p/4507986.html

你可能感兴趣的文章
渲染机制/页面性能/错误监控
查看>>
Dom中高big 事件总结(持续更新中)
查看>>
Immutable.js 源码解析 --List 类型
查看>>
【修真院“善良”系列之十六】代码结构中Dao,Service,Controller,Util,Model是什么意思,为什么划分...
查看>>
js数据结构-栈
查看>>
前端构建_webpack
查看>>
Looper源码
查看>>
微信小程序开发系列五:微信小程序中如何响应用户输入事件
查看>>
程序员如何优雅的记录笔记(同步云端,图床,多端发布)
查看>>
极速高清——给你带来全新的高清视野
查看>>
数据结构之链表【上】
查看>>
Go并发实战笔记整理
查看>>
我们的手机用上北斗导航了吗?
查看>>
6年来,Docker的这些变化你都知道吗?
查看>>
支付宝客户端架构解析:iOS 客户端启动性能优化初探
查看>>
Maven之pom.xml配置文件详解(转载)
查看>>
优化Git本地仓库
查看>>
对.NET Core未来发展趋势的浅层判断
查看>>
Python高级知识点学习(七)
查看>>
《人月神话》(P7)编写手册和组织开会
查看>>