热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

linux上使用cmake安装mysql的方法

小编给大家分享一下linux上使用cmake安装mysql的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!方法:1、安装ncurses-devel依

小编给大家分享一下linux上使用cmake安装mysql的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

方法:1、安装ncurses-devel依赖包;2、下载并解压mysql压缩包;3、使用cd命令进入mysql文件夹,使用cmake命令进行配置解析;4、使用“make && make install”命令安装mysql即可。

一、安装cmake

1、解压cmake压缩包

[root@mysql tools]# tar -zvxf cmake-2.8.8.tar.gz
[root@mysql tools]# ls
cmake-2.8.8 cmake-2.8.8.tar.gz mysql-5.5.16.tar.gz scripts

2、解析

[root@mysql tools]# cd cmake-2.8.8
[root@mysql cmake-2.8.8]# ./configure
---------------------------------------------
CMake 2.8.8, Copyright 2000-2009 Kitware, Inc.
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
Makefile processor on this system is: gmake
g++ is GNU compiler
g++ has STL in std:: namespace
g++ has ANSI streams
g++ has streams in std:: namespace

3、安装

[root@mysql cmake-2.8.8]# echo $?
0
#如果返回值是0,就是执行成功,如果返回值是1,就是执行失败;

[root@mysql cmake-2.8.8]# gmake && gmake install
Scanning dependencies of target cmIML_test
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test.c.o
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_C.c.o
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_C.c.o
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_include_C.c.o
[ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_CXX.cxx.o
[ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_CXX.cxx.o
[ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_include_CXX.cxx.o

二、开始安装mysql

1、首先需要安装(ncurses-devel)依赖包

[root@mysql cmake-2.8.8]# cd …
[root@mysql tools]# yum -y install ncurses-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

base: mirrors.zju.edu.cn
extras: centos.ustc.edu.cn
updates: mirrors.zju.edu.cn
Resolving Dependencies
–> Running transaction check
—> tools ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed
#############安装完成后检查###########
[root@mysql tools]# rpm -qa | grep ncurses-devel
ncurses-devel-5.9-14.20130511.el7_4.x86_64
[root@mysql tools]#

2、解压mysql压缩包

[root@mysql tools]# tar -zvxf mysql-5.5.16.tar.gz
[root@mysql tools]# ls
cmake-2.8.8 cmake-2.8.8.tar.gz mysql-5.5.16 mysql-5.5.16.tar.gz scripts
[root@mysql tools]#

3、创建虚拟用户

[root@mysql tools]# useradd mysql -s /sbin/nologin -M
[root@mysql tools]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
[root@mysql tools]#

4、配置解析

[root@mysql tools]# cd mysql-5.5.16
[root@mysql mysql-5.5.16]#
[root@mysql mysql-5.5.16]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.16 -DMYSQL_DATADIR=/usr/local/mysql-5.5.16/data -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.16/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -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 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0

5、安装

[root@mysql mysql-5.5.16]# make && make install
Scanning dependencies of target INFO_BIN
[ 0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[ 0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[ 0%] Built target abi_check
Scanning dependencies of target zlib

6、创建软连接

[root@mysql mysql-5.5.16]# ln -s /usr/local/mysql-5.5.16/ /usr/local/mysql
[root@mysql mysql-5.5.16]# readlink /usr/local/mysql
/usr/local/mysql-5.5.16/
[root@mysql mysql-5.5.16]#

7、配置环境

[root@mysql mysql-5.5.16]# cd …
[root@mysql tools]# echo ‘export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile

[root@mysql tools]# tail -1 /etc/profile
export PATH=/usr/local/mysql/bin:$PATH

[root@mysql tools]# source /etc/profile
[root@mysql tools]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@mysql tools]#

8、拷贝、查看、设置属主、及添加tmp权限

[root@mysql tools]# \cp mysql-5.5.16/support-files/my-small.cnf /etc/my.cnf
[root@mysql tools]# ll /usr/local/mysql/data/
total 0
drwxr-xr-x 2 root root 20 May 31 11:51 test
[root@mysql tools]# chown -R mysql.mysql /usr/local/mysql/data/
[root@mysql tools]# chmod -R 1777 /tmp/
[root@mysql tools]#

9、初始化数据库

[root@mysql tools]# cd /usr/local/mysql/scripts/
[root@mysql scripts]# ./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
Installing MySQL system tables…
OK
Filling help tables…
OK

注:看到两个ok表示成功

10、设置开机启动

[root@mysql scripts]# cd /roottools/mysql-5.5.16
[root@mysql mysql-5.5.16]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mysql mysql-5.5.16]# chmod -R 755 /etc/init.d/mysqld
[root@mysql mysql-5.5.16]# chkconfig --add mysqld
[root@mysql mysql-5.5.16]# chkconfig mysqld on
[root@mysql mysql-5.5.16]# chkconfig --list mysqld

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

If you want to list systemd services use ‘systemctl list-unit-files'.
To see services enabled on particular target use
‘systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mysql mysql-5.5.16]#

11、启动mysql数据库

[root@mysql mysql-5.5.16]# /etc/init.d/mysqld start
Starting MySQL… SUCCESS!
[root@mysql mysql-5.5.16]#

12、查看端口进程

[root@mysql mysql-5.5.16]# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 51146 mysql 10u IPv4 82600 0t0 TCP :mysql (LISTEN)
[root@mysql mysql-5.5.16]# netstat -lnutp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 51146/mysqld
[root@mysql mysql-5.5.16]# ps -ef|grep 3306
mysql 51146 50900 0 14:13 pts/1 00:00:00 /usr/local/mysql-5.5.16/bin/mysqld --basedir=/usr/local/mysql-5.5.16 --datadir=/usr/local/mysql-5.5.16/data --plugin-dir=/usr/local/mysql-5.5.16/lib/plugin --user=mysql --log-error=/usr/local/mysql-5.5.16/data/mysql.err --pid-file=/usr/local/mysql-5.5.16/data/mysql.pid --socket=/usr/local/mysql-5.5.16/tmp/mysql.sock --port=3306
root 51170 16240 0 14:14 pts/1 00:00:00 grep --color=auto 3306
[root@mysql mysql-5.5.16]#

注:如果要重新初始化只要删除data目录库文件存储地或者新建一个库文件存储地,重新初始化,提示两个ok就是成功

进入数据库

[root@localhost ~]# mysql

查看所有用户

mysql> use mysql
mysql> show tables;
mysql> select user,host from user;

删除系统默认的

delete from mysql.user where user='';
delete from mysql.user where host='::1';
select user,host from mysql.user;

只保留这两个

mysql> select user,host from mysql.user;
±-----±----------+
| user | host |
±-----±----------+
| root | 127.0.0.1 |
| root | localhost |
±-----±----------+
2 rows in set (0.00 sec)

mysql>
#########################

添加额外的授权管理员用户

grant all privileges on . to system@‘192.168.%' identified by ‘system' with grant option;

字符集路径

vi /etc/locale.conf #centos7

mysql创建密码

/application/mysql//bin/mysqladmin -u root password ‘123456'

mysql修改密码

/application/mysql//bin/mysqladmin -u root -p123456 password ‘112233'

看完了这篇文章,相信你对linux上使用cmake安装mysql的方法有了一定的了解,想了解更多相关知识,欢迎关注编程笔记行业资讯频道,感谢各位的阅读!


推荐阅读
  • 本文介绍了使用PHP实现断点续传乱序合并文件的方法和源码。由于网络原因,文件需要分割成多个部分发送,因此无法按顺序接收。文章中提供了merge2.php的源码,通过使用shuffle函数打乱文件读取顺序,实现了乱序合并文件的功能。同时,还介绍了filesize、glob、unlink、fopen等相关函数的使用。阅读本文可以了解如何使用PHP实现断点续传乱序合并文件的具体步骤。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • Java实战之电影在线观看系统的实现
    本文介绍了Java实战之电影在线观看系统的实现过程。首先对项目进行了简述,然后展示了系统的效果图。接着介绍了系统的核心代码,包括后台用户管理控制器、电影管理控制器和前台电影控制器。最后对项目的环境配置和使用的技术进行了说明,包括JSP、Spring、SpringMVC、MyBatis、html、css、JavaScript、JQuery、Ajax、layui和maven等。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 本文探讨了C语言中指针的应用与价值,指针在C语言中具有灵活性和可变性,通过指针可以操作系统内存和控制外部I/O端口。文章介绍了指针变量和指针的指向变量的含义和用法,以及判断变量数据类型和指向变量或成员变量的类型的方法。还讨论了指针访问数组元素和下标法数组元素的等价关系,以及指针作为函数参数可以改变主调函数变量的值的特点。此外,文章还提到了指针在动态存储分配、链表创建和相关操作中的应用,以及类成员指针与外部变量的区分方法。通过本文的阐述,读者可以更好地理解和应用C语言中的指针。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • 本文讨论了clone的fork与pthread_create创建线程的不同之处。进程是一个指令执行流及其执行环境,其执行环境是一个系统资源的集合。在调用系统调用fork创建一个进程时,子进程只是完全复制父进程的资源,这样得到的子进程独立于父进程,具有良好的并发性。但是二者之间的通讯需要通过专门的通讯机制,另外通过fork创建子进程系统开销很大。因此,在某些情况下,使用clone或pthread_create创建线程可能更加高效。 ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
  • 达人评测 酷睿i5 12450h和锐龙r7 5800h选哪个好 i512450h和r75800h对比
    本文介绍了达人评测酷睿i5 12450h和锐龙r7 5800h选哪个好的相关知识,包括两者的基本配置和重要考虑点。希望对你在选择时提供一定的参考价值。 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
author-avatar
京丿城考拉U_967
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有