Linux下编译安装MySQL安装

博主邮箱www.zzher@foxmail.com   qq:1102471911

编译安装MySQL

准备工作:

1、获得以下所需的源代码包,并存放在/usr/local/src(建议用Xshell远程连接,Xshell使用方法见另一边文章)
  与mysql相关:

  • boost_1_59_0.tar.gz
  • cmake-3.6.2.tar.gz
  • mysql-5.7.16.tar.gz

2、安装cmake前的依赖包的安装
  检查gcc-c++ 、ncurses-devel是否安装,如果没有安装,先用yum进行安装,也可以用编译安装的方法,编译安装的方法在首页有介绍

安装:

1、编译安装cmake工具

1 cd /usr/local/src
2 tar xf cmake-3.6.2.tar.gz
3 cd cmake-3.6.2
4 ./bootstrap --prefix=/usr/local/cmake
5 make
6 make install  #如果前面没有指定安装目录,则默认安装到/usr/local/bin/cmake

2、建立mysql组和用户,并将mysql用户添加到mysql组

1 groupadd mysql
2 useradd -g mysql mysql
3 创建mysql数据文件存放的目录
4 mkdir /mysqldata
5 chown mysql:mysql /mysqldata
6 chmod o= /mysqldata              #设置其他人没有任何权限

3、编译安装mysql

1 cd /usr/local/src
2 tar xf mysql-5.7.16.tar.gz
3 cd mysql-5.7.16
4 /usr/local/cmake/bin/cmake .  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.7  -DMYSQL_DATADIR=/mysqldata -DWITH_BOOST=/usr/local/src  -DSYSCONFDIR=/etc  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1  -DEXTRA_CHARSETS=all  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_DEBUG=0  -DMYSQL_MAINTAINER_MODE=0  -DWITH_SSL:STRING=bundled  -DWITH_ZLIB:STRING=bundled
5 make && make install

4、更改mysql安装目录的属主属组并添加mysql环境变量

1 chown -R mysql:mysql /usr/local/mysql5.7
2 vim /etc/profile.d/mysql.sh
3 文件内容是:
4 export PATH=$PATH:/usr/local/mysql/bin
5 执行命令:
6 bash                          #让新的PATH变量生效

5、加入服务列表并设置为开机自启

1 cd /usr/local/mysql/support-files
2 cp mysql.server  /etc/init.d/mysqld
3 chmod +x /etc/init.d/mysqld
4 chkconfig mysqld on

6、修改mysql的配置文件

 1 vim /etc/my.cnf
 2
 3 [mysql]
 4 socket=/tmp/mysql.sock
 5
 6 [mysqld]
 7 datadir=/mydata
 8 socket=/tmp/mysql.sock
 9 user=mysql
10 symbolic-links=0
11
12 [mysqld_safe]
13 log-error=/var/log/mysqld.log
14 pid-file=/mydata/mysqld.pid

7、初始化mysql

1 mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata说明:##“-–initialize”会生成一个随机密码(~/.mysql_secret),而”–initialize-insecure”不会生成密码 ##user表示指定用户 ##basedir表示mysql的安装路径,datadir表示数据库文件存放路径

8、启动mysql服务

# service mysqld start
查看MySQL服务的进程和端口
# ps -ef | grep mysqld
root     22306     1  0 12:51 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mydata --pid-file=/mydata/web1.deng.com.pid
mysql    22480 22306 12 12:51 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mydata --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/mydata/web1.deng.com.pid --socket=/tmp/mysql.sock
# netstat -an | grep :3306
tcp        0      0 :::3306                     :::*                        LISTEN

9、查看MySQL服务的进程和端口

1 # ps -ef | grep mysqld
2 root     22306     1  0 12:51 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mydata --pid-file=/mydata/web1.deng.com.pid
3 mysql    22480 22306 12 12:51 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mydata --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/mydata/web1.deng.com.pid --socket=/tmp/mysql.sock
4
5 # netstat -an | grep :3306
6 tcp        0      0 :::3306                     :::*                        LISTEN

10、初始化MySQL数据库的root用户密码

 1 # mysql_secure_installation
 2
 3 Securing the MySQL server deployment.
 4
 5 Connecting to MySQL using a blank password.
 6
 7 VALIDATE PASSWORD PLUGIN can be used to test passwords
 8 and improve security. It checks the strength of password
 9 and allows the users to set only those passwords which are
10 secure enough. Would you like to setup VALIDATE PASSWORD plugin?
11
12 Press y|Y for Yes, any other key for No: y                  #需要修改密码,所以输入y
13
14 There are three levels of password validation policy:
15
16 LOW    Length >= 8
17 MEDIUM Length >= 8, numeric, mixed case, and special characters
18 STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
19
20 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2          #设置密码复杂度为强
21 Please set the password for root here.
22
23 New password:
24
25 Re-enter new password:                                      #输入2次新密码
26
27 Estimated strength of the password: 100
28 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
29 By default, a MySQL installation has an anonymous user,
30 allowing anyone to log into MySQL without having to have
31 a user account created for them. This is intended only for
32 testing, and to make the installation go a bit smoother.
33 You should remove them before moving into a production
34 environment.
35
36 Remove anonymous users? (Press y|Y for Yes, any other key for No) : y   #删除匿名用户
37 Success.
38
39
40 Normally, root should only be allowed to connect from
41 'localhost'. This ensures that someone cannot guess at
42 the root password from the network.
43
44 Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y     #禁止root远程登录
45
46  ... skipping.
47 By default, MySQL comes with a database named 'test' that
48 anyone can access. This is also intended only for testing,
49 and should be removed before moving into a production
50 environment.
51
52
53 Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y  #删除测试数据库
54  - Dropping test database...
55 Success.
56
57  - Removing privileges on test database...
58 Success.
59
60 Reloading the privilege tables will ensure that all changes
61 made so far will take effect immediately.
62
63 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y  #重新加载权限表
64 Success.
65
66 All done! 

11、将MySQL数据库的动态链接库共享至系统链接库

1 vim /etc/ld.so.conf.d/mysql.conf
2 文件内容是:
3 /usr/local/mysql/lib
4
5 ldconfig -v           让系统重新读取库文件

12、测试登陆MySQL数据库

 1 # mysql -uroot -p
 2 Enter password:             #输入刚才设置的新密码
 3 Welcome to the MySQL monitor.  Commands end with ; or \g.
 4 Your MySQL connection id is 5
 5 Server version: 5.7.14 Source distribution
 6
 7 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
 8
 9 Oracle is a registered trademark of Oracle Corporation and/or its
10 affiliates. Other names may be trademarks of their respective
11 owners.
12
13 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
14
15 mysql> show databases;
16 +--------------------+
17 | Database           |
18 +--------------------+
19 | information_schema |
20 | mysql              |
21 | performance_schema |
22 | sys                |
23 +--------------------+
24 4 rows in set (0.00 sec)
25
26 mysql> exit
27 Bye

到此,linux下的MySQL安装完毕!做需要的文件在后面网盘自行下载

如有错误请及时指出,谢谢!

CentOS-6.8-x86_64-bin-DVD1.iso

链接:https://pan.baidu.com/s/1hSjlElLDz7F4E2Ese0AMKA
提取码:wsb3

cmake-3.6.2.tar.gz

链接:https://pan.baidu.com/s/1VNENQic4iK9pS0uT94QNHQ 

提取码:rnii
boost_1_59_0.tar.gz

链接:https://pan.baidu.com/s/1GrAEYekiq5t-D4TRQQeptQ
提取码:dviz

mysql-5.7.16.tar.gz

链接:https://pan.baidu.com/s/1_Gk3P7nUb7D3B3JOCF7w_g
提取码:qktl

posted @ 2019-01-08 21:33 DBA_zzher 阅读( ...) 评论( ...) 编辑 收藏

Linux下编译安装MySQL安装相关推荐

  1. Linux下编译连接mysql数据库

    1.在Linux下编译连接mysql数据库的程序时,需要使用安装Mysql数据库时自带的mysql_config脚本.它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.需要使用下面 ...

  2. Linux下eclipse及mysql安装,c++访问mysql数据库

    这两天在学习linux下用c++访问mysql,碰到一堆问题,记录一下. 1.mysql安装: 公司的电脑是64位的,安装的是64为的RHEL4,安装如下三个包: MySQL-client-5.1.4 ...

  3. rmp mysql_整理linux 下rmp格式Mysql安装

    因为要升级Mysql版本,在linux rpm完全卸载mysql过程如下: 1.查找安装的mysql: [root@host ~]# rpm -qa | grep mysql mysql-server ...

  4. linux 安装nginx php mysql 配置文件在哪_linux下 php+nginx+mysql安装配置

    我主要是用来安装php,以及nginx和php的交互. 一 安装插件 可以选择YUM安装或者源码编译安装gccgcc-c++zlib pcre pcre-devel libevent libevent ...

  5. linux下编译libuv,linux下libuv库安装教程

    下载并编译libuv libuv需要自己手动下载源码,并手动编译. 当前目录为:/home/xlz/test/github/,在后面,会用$PATH来代替,我的系统的Debian8,64bit. $g ...

  6. mysql 5.5 安装 linux,linux下mysql5.5的安装

    #rpm –qa|grep –i mysql查看已安装的mysql版本 如果有已存在的mysql版本则删除 安装服务端和客户端,去Oracle官网下载: # rpm -ivh MySQL-serve ...

  7. linux 保存编译log,(转)Linux下编译安装log4cxx

    一个项目的服务器端在Linux平台下,用到了开源日志库log4cxx,这个库是apache项目的一个子库.功能很不错.下面记录下它的编译和安装过程. 第一步安装apr-1.3.8,顺序不能错,它必须首 ...

  8. java libpcap,Linux下编译安装libpcap

    要做Sniffer了,先在Linux下编译一下libpcap 1.编译安装flex #libpcap 1.1要求flex必须在2.4.6及以上 wget http://prdownloads.sour ...

  9. linux下编译安装MySQL5.6新版本

    MySQL 5.5以上版本 与之前的版本安装出入有些区别: 下面是安装过程 mysql5.6 下载地址: ftp://mirror.switch.ch/mirror/mysql/Downloads/M ...

最新文章

  1. Kaggle金牌拿Offer有多简单?
  2. 全局性业务架构建模工作步骤
  3. Java与汽车_Java NIO:IO与NIO的区别
  4. [十一]SpringBoot 之 添加JSP支持
  5. 2023年多播ABR市场将达8亿美元
  6. python命令行解析_python命令行解析函数
  7. Python学习第三天
  8. 中心静脉导管行业调研报告 - 市场现状分析与发展前景预测(2021-2027年)
  9. ubuntu下查看apache的日志
  10. refprop用matlab,Matlab 调用 REFPROP(64位)下载即可用
  11. java json nf_什么是JSON ,API,GET,POST请求
  12. MATLAB符号运算部分知识总结
  13. pandas获取全部列名_pandas获取全部列名_pandas DataFrame数据重命名列名的几种方式...
  14. 简单5分钟,将lowcode低代码融入到你的中后台管理系统
  15. c语言课程设计日程表,日程表:schedule用法大全
  16. 计算机学院主管学生日常工作的是,学生会的年度计划书(网络版)doc(完整版)...
  17. 华清远见-重庆中心-JAVA高级阶段知识点梳理
  18. (附源码)anjule客户信息管理系统 毕业设计 181936
  19. AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/yolov5-5.0/models/commo
  20. frame/frameset/iframe的区别

热门文章

  1. 年度计划:2018 不畏将来
  2. wampserver wordpress 外网访问时网页图片无法显示
  3. js延迟执行dom操作(函数节流)
  4. 推荐给大家一个php代码格式化在线工具
  5. Enabled设置为False时,前景色和背景色也不改变的TextBox 并居中
  6. c语言long long int怎么用,在Dev C++下,使用long long int
  7. Idea使用Gson解析Json步骤
  8. 勒索病毒发生变种 新文件名将带有“.UIWIX”后缀
  9. 产品分析报告-作业帮
  10. FMD基于视觉的材料识别数据集