获得以下所需的源代码包,并存放在/usr/local/src

与mysql相关:boost_1_59_0.tar.gz cmake-3.6.2.tar.gz mysql-5.7.16.tar.gz

安装cmake前的依赖包的安装:

检查gcc-c++ 、ncurses-devel是否安装,如果没有安装,先用yum进行安装

编译安装cmake工具

cd /usr/local/src

tar xf cmake-3.6.2.tar.gz

cd cmake-3.6.2

./bootstrap --prefix=/usr/local/cmake

make

make install             //如果前面没有指定安装目录,则默认安装到/usr/local/bin/cmake

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

groupadd mysql

useradd -g mysql mysql

创建mysql数据文件存放的目录

mkdir /mydata

chown mysql:mysql /mydata

chmod o= /mydata           //设置其他人没有任何权限

编译安装mysql

cd /usr/local/src

tar xf mysql-5.7.16.tar.gz

cd mysql-5.7.16

/usr/local/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata -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

make && make install

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

chown -R mysql:mysql /usr/local/mysql

vim /etc/profile.d/mysql.sh

文件内容是: export PATH=$PATH:/usr/local/mysql/bin

执行命令:bash //让新的PATH变量生效

安装时/usr/local/mysql目录找不到怎么办?

查找资料说需要单独安装Development Libraries开发包

[root@centos6-y ~]#

sudo rpm -ivh mysql-community-devel-5.7.13-1.el7.x86_64.rpm

[sudo] password for home:

warning: mysql-community-devel-5.7.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

libmysqlclient.so.20()(64bit) is needed by mysql-community-devel-5.7.13-1.el7.x86_64

mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-devel-5.7.13-1.el7.x86_64

[ocsr90@localhost temp]$ sudo rpm -ivh mysql-community-devel-5.7.13-1.el7.x86_64.rpm --nodeps --noforce

rpm: --noforce: unknown option

[ocsr90@localhost temp]$ sudo rpm -ivh mysql-community-devel-5.7.13-1.el7.x86_64.rpm --nodeps --force

warning: mysql-community-devel-5.7.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

1:mysql-community-devel-5.7.13-1.el################################# [100%]

安装完,目录/usr/include/mysql存在了

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

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig mysqld on

修改mysql的配置文件

cat /etc/my.cnf

[mysql]

socket=/tmp/mysql.sock

[mysqld]

datadir=/mydata

socket=/tmp/mysql.sock

user=mysql

symbolic-links=0

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/mydata/mysqld.pid

初始化mysql

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata

说明:

##“-–initialize”会生成一个随机密码(~/.mysql_secret),而”–initialize-insecure”不会生成密码。

##user表示指定用户 ##basedir表示mysql的安装路径,datadir表示数据库文件存放路径。

启动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

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

# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y #需要修改密码,所以输入y

There are three levels of password validation policy:

LOW Length >= 8

MEDIUM Length >= 8, numeric, mixed case, and special characters

STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 #设置密码复杂度为强

Please set the password for root here.

New password:

Re-enter new password: #输入2次新密码

Estimated strength of the password: 100

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y #删除匿名用户

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y #禁止root远程登录

... skipping.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y #删除测试数据库

- Dropping test database...

Success.

- Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y #重新加载权限表

Success.

All done!

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

vim /etc/ld.so.conf.d/mysql.conf

文件内容是:

/usr/local/mysql/lib

ldconfig -v //让系统重新读取库文件

测试登陆MySQL数据库

# mysql -uroot -p

Enter password: #输入刚才设置的新密码

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.14 Source distribution

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

| sys |

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

4 rows in set (0.00 sec)

mysql>exit

Bye

linux系统编译安装mysql_Linux下编译安装MySQL相关推荐

  1. linux虚拟机上离线安装mysql_Linux下离线安装MySQL

    Linux下安装mysql 1 检查并卸载已安装mysql 命令:rpm -qa|grep -i mysql 命令:rpm -e --nodeps '上个命令后显示的本机已安装mysql依赖' 如果存 ...

  2. docker 离线安装 mysql_Linux下离线安装Docker

    一.基础环境 1.操作系统:CentOS 7.3 2.Docker版本:18.06.1 官方下载地址 3.百度云Docker 18.06.1地址:链接:https://pan.baidu.com/s/ ...

  3. linux防火墙文件路径,防火墙问题 Linux系统 /etc/sysconfig/路径下无iptables文件

    虚拟机新装了一个CentOs7,然后做防火墙配置的时候找不到iptables文件,解决方法如下: 因为默认使用的是firewall作为防火墙,把他停掉装个iptable systemctl stop ...

  4. linux编译blas,Linux系统CentOS 6.8上yum安装BLAS库

    Linux系统CentOS 6.8上yum安装BLAS库 BLAS是一个广泛应用到科学计算软件上面的库文件,在CentOS的软件库中已经有该软件的软件包,我们可以直接使用yum来安装. 1.1.查询C ...

  5. ThinkPad物理机安装Linux系统实战企业级项目之CentOS安装

    ThinkPad物理机安装Linux系统实战企业级项目之CentOS安装 系统安装 下载CentOS系统制作系统U盘 笔记本电源设置 网络设置 WiFi类型查看验证设置联网 设置固定IP 安装MySQ ...

  6. linux 编译 suitesparse,Ubuntu下编译SuiteSparse-4.4.1和METIS-4.0.3

    ubuntu下编译caffe Ubuntu下编译caffe 纯粹是个人编译的记录.不用CUDA(笔记本是amd卡,万恶的nvidia):不手动编译依赖包(apt-get是用来干啥的?用来直接装二进制包 ...

  7. linux系统连接校园无线网卡,RedHat Linux系统能不能连接无线网 如何安装无线网卡驱动 - 驱动管家...

    想要使用RedHat Linux系统实现无线上网,就要先安装无线网卡驱动,这是在任何一个操作系统中不变的真理.那么RedHat Linux系统如何安装无线网卡驱动呢? 输入命令lsusb,可以看到US ...

  8. 在笔记本上安装 linux系统--Ubuntu 20.04(实体机安装而非虚拟机)

    在笔记本上安装 linux系统–Ubuntu 20.04(实体机安装而非虚拟机) 一.刻录操作系统镜像到U盘 Ubuntu有详细的操作说明(5分钟左右能看完)大概如下 Create a bootabl ...

  9. frdora10_a8_linux,8楼 【A8】 linux系统的不刻盘的安装 一:.pdf

    8楼 [A8] linux系统的不刻盘的安装 一: 8 楼 [A8] linux 系统的不刻盘的安装 一: [A8] linux 系统的不刻盘的安装 一: 目录: ①,打造 windows xp 与 ...

最新文章

  1. 4.12 《硬啃设计模式》 第29章 行为型设计模式小结
  2. C++实现的简单vector
  3. C++ 标准库中的异常
  4. 海外净利润低?海尔智家H股上市有望看齐国内!
  5. GDCM:gdcm::MediaStorage的测试程序
  6. SQL语句错误:Operand should contain 1 column(s)【查询多个字段不用加括号】
  7. [译]SQL SERVER 2016 – Temporal Tables
  8. 大联合 - 单细胞测序在新冠肺炎研究中的应用进展 (PPT)
  9. 信息学奥赛C++语言:猴子选大王
  10. 用自己电脑做服务器,建个人网站
  11. java 占位符_Java重要知识点
  12. 浅谈一次QQ被盗取(攻击)事件
  13. 程序设计基础是C语言吗,程序设计基础(C语言)
  14. 用 Python 搭建解一元二次方程的计算器
  15. AI:人工智能领域之AI发展历史的重要历史时间节点、大牛们对AI相关概念的定义
  16. Win10 中主机名hosts 文件位置
  17. windows10无法使用内置管理员账户打开应用
  18. centos 6 升级gcc
  19. 如何使用Win10搭建我的世界Minecraft服务器
  20. spyder配置文件位置及使用说明

热门文章

  1. 第一章 动态规划【未完结】
  2. 【PAT乙级】1061 判断题 (15 分)
  3. MySQL普通用户修改密码
  4. lottie插件_RN常用插件集
  5. 一直认为 count(1) 比 count(*) 效果高,被同事鄙视了。
  6. 跟前腾讯总监学Java实战项目
  7. 牛人 20000 字的 Spring Cloud 总结,太硬核了~
  8. java网络编程(五)
  9. 设计模式——开发常用的设计模式梳理
  10. 寻找数组中最小的k个数(快排和堆排)