mysql 5.7下载地址

社区版下载地址:https://dev.mysql.com/downloads/mysql/ 可能会有变动

找到5.7版本,

注:源码安装需要用到下面的包,可以先忽略,我安装是提示用到的不是这个版本的包,而且无法解压此包,安装提示中用到的是此包boost_1_59_0.tar.gz,可以连接外网的的情况下,能自动下载安装,没有也不要担心,会在报错页面,给出下载url地址,可以下载后本地上传至服务器中。

或者通过wget下载

wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12.tar.gz

环境准备

# cat /etc/centos-release

CentOS Linux release 7.6.1810 (Core)

# uname -r

3.10.0-957.el7.x86_64

# getenforce

Disabled

# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

Active: inactive (dead)

Docs: man:firewalld(1)

编译MySQL

解决依赖关系

# yum -y install autoconf automake libtool cmake ncurses-devel openssl-devel lzo-devel zlib-devel gcc gcc-c++ bison bison-devel git libaio-devel

注:下面所有的名利都要用绝对路径避免出错。

创建用户MySQL启动用户

groupadd mysql

useradd -r -g mysql -s /bin/false -M mysql

解压MySQL压缩包

# tar xf mysql-5.7.25

# cd mysql-5.7.25

进入解压目录并将boost_1_59_0.tar.gz放入mysql-5.7.25

# 创建文件目录

mkdir -p /application/mysql-5.7.25

编译安装MySQL

cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.25/ -DSYSCONFDIR=/application/mysql-5.7.25/ -DMYSQL_DATADIR=/application/mysql-5.7.25/mysqldata -DMYSQL_UNIX_ADDR=/application/mysql-5.7.25/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=.

-DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.25/   #安装位置

-DSYSCONFDIR=/application/mysql-5.7.25/        #配置文件(my.cnf)目录

-DMYSQL_DATADIR=/application/mysqlData        #数据存储目录

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock             #mysql.sock目录

-DMYSQL_TCP_PORT=3306                         #服务端口

-DMYSQL_USER=mysql                            #运行用户

-DEXTRA_CHARSETS=all                          #扩展字符支持

-DDEFAULT_CHARSET=utf8                        #默认字符集

-DDEFAULT_COLLATION=utf8_general_ci           #默认字符校对

-DWITH_READLINE=1                             #readline库

-DENABLED_LOCAL_INFILE=1                      #启用加载本地数据

-DWITH_MYISAM_STORAGE_ENGINE=1                #使用Myisam存储引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1           #使用INNOBASE存储引擎

-DWITH_PARTITION_STORAGE_ENGINE=1             #安装数据库分区

-DWITH_MEMORY_STORAGE_ENGINE=1                #安装memory存储引擎

-DDOWNLOAD_BOOST=1                            #下载升压文件boost_1_59_0.tar.gz

-DWITH_BOOST=.               #指定boots文件位置,点表示当前位置,也可以用绝对路径,开始时因为将文件上传至此目录内,所以用点指定即可。

注:注意磁盘空间,不满足的情况下也是会编译失败的,最少给MySQL准备10G空间。

# make && make install

复制启动程序

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

注:centos7中,init.d下的启动文件要配置755权限,才可以使用,安装包中含有systemctl启动文件,可以用systemctl管理MySQL。

注:mysql。sock文件存放位置要设置成mysql:mysql用户,不然会提示没有sock文件。

设置mysql环境变量:

# echo "export PATH=/application/mysql/bin:/application/mysql/lib:$PATH" >>/root/.bash_profile

# source /root/.bash_profile

修改mysql权限

# chown -R mysql:mysql /application/*

创建软连接,MySQL升级后可以指定新的目录

# ln -s # ln -s /application/mysql-5.7.25 /application/mysql

配置my.cnf

# vim /etc/my.cnf

[client]

port = 3306

socket = /var/lib/mysql/mysql.sock

default-character-set = utf8

[mysqld]

port = 3306

socket = /var/lib/mysql/mysql.sock

basedir = /application/mysql

datadir = /application/mysqlDate

pid-file = /application/mysqlDate/mysql.pid

user = mysql

bind-address = 0.0.0.0

server-id = 1

init-connect = 'SET NAMES utf8mb4'

character-set-server = utf8mb4

skip-name-resolve

#skip-networking

back_log = 300

max_connections = 1000

max_connect_errors = 6000

open_files_limit = 65535

table_open_cache = 128

max_allowed_packet = 4M

binlog_cache_size = 1M

max_heap_table_size = 8M

tmp_table_size = 16M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

sort_buffer_size = 8M

join_buffer_size = 8M

key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1

query_cache_size = 8M

query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 30

log_error = /application/mysqlDate/mysql-error.log

slow_query_log = 1

long_query_time = 1

slow_query_log_file = /application/mysqlDate/mysql-slow.log

performance_schema = 0

explicit_defaults_for_timestamp

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB

#default-storage-engine = MyISAM

innodb_file_per_table = 1

innodb_open_files = 500

innodb_buffer_pool_size = 64M

innodb_write_io_threads = 4

innodb_read_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 1

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 2M

innodb_log_file_size = 32M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M

myisam_sort_buffer_size = 8M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

interactive_timeout = 28800

wait_timeout = 28800

[mysqldump]

quick

max_allowed_packet = 16M

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

read_buffer = 4M

write_buffer = 4M

启动MySQL

# /etc/init.d/mysqld restart

# ps -ef |grep mysql

root      11478      1  0 14:13 pts/0    00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --datadir=/application/mysqlDate --pid-file=/application/mysqlDate/mysql.pid

mysql     12320  11478  8 14:13 pts/0    00:00:00 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/application/mysqlDate --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/application/mysqlDate/mysql-error.log --open-files-limit=65535 --pid-file=/application/mysqlDate/mysql.pid --socket=/var/lib/mysql/mysql.sock --port=3306

# netstat -antup|grep mysql

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      12320/mysqld

MySQL初始化

# MySQL5.7已经不推荐使用mysql_install_db初始化数据库了

进行一些安全设置,以及修改数据库管理员密码

# /application/mysql/bin/mysql_sceure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

注意:建议对所有Mariadb运行此脚本的所有部分生产中使用的服务器!请仔细阅读每一步!

In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.  If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.

Enter current password for root (enter for none):   回车即可

OK, successfully used password, moving on...

为了登录Mariadb以保护它,我们需要MariaDB根用户的密码。如果你刚刚安装了Mariadb,您尚未设置根密码,密码将为空,所以你只需在这里按回车键。

Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.

Set root password? [Y/n]

设置根密码确保没有人可以登录mariadb未经适当授权的根用户。设置根密码?[y/n]   #这里选择y,如果出现报错说明你没有用绝对路径,所有命令都是运行在据对路径下的,可以通过配置PATH来使命令生效。

By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.

Remove anonymous users? [Y/n]

默认情况下,Mariadb安装有匿名用户,允许任何人登录Mariadb而不必为其创建用户帐户他们。仅用于测试和安装稍微平稳一点。在移动到生产环境。

删除匿名用户?[y/n]  #这里y清除匿名用户。

Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]

通常,只允许根目录从“localhost”连接。这个确保有人无法猜测网络中的根密码。

不允许远程登录根目录?[y/n] # 这里选择y

By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.

Remove test database and access to it? [Y/n]

默认情况下,Mariadb附带一个名为“test”的数据库,任何人都可以访问该数据库。这也仅用于测试,在进入生产环境之前应将其移除。

删除测试数据库并访问它?[y/n]  #这里选y

Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.

Reload privilege tables now? [Y/n]、

重新加载特权表将确保所做的所有更改立即生效。

现在重新加载特权表?[y/n]  #这里选择y

此时初始化及安全初始化就算做完了。

MySQL密码更改方法:

# ./mysqladmin -uroot -p password   #enter

第一次输入原密码

第二次输入新密码

第三次验证新密码

登录进MySQL后输入下面命令

修改mysql的用户密码,分别使用grant、alter、set修改

l  grant all on *.* to '用户名'@'登录主机' identified by '密码';

l  alter user '用户名'@'登录主机' identified by '密码(自定义)';

l  set password for 'root'@'localhost' = password('new password');

#所有修改密码操作,完成后都需要执行下边的命令

flush privileges;

忘记密码修改方法:

l  修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1

l  这一行配置让 mysqld 启动时不对密码进行验证

l  重启 mysqld 服务:systemctl restart mysqld

l  使用 root 用户登录到 mysql:mysql -u root

l  切换到mysql数据库,更新 user 表:

l  update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';

l  在之前的版本中,密码字段的字段名是 password,5.7版本改为了 authentication_string

l  退出 mysql,(exit或者quit)编辑 /etc/my.cnf 文件,删除 skip-grant-tables=1 的内容

l  重启 mysqld 服务,再用新密码登录即可

CentOS7.x安装MySQL5.7.25的更多相关文章

  1. Centos7二进制文件安装MySQL5.7.25

    1.删除centos系统自带的mariadb数据库防止发生冲突 rpm -qa|grep mariadb rpm -e mariadb-libs --nodeps 2.安装libaio库 yum -y ...

  2. Centos7 yum安装MySQL5.7.25

    1 下载并安装MySQL官方的 Yum Repository[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-commun ...

  3. 【MySQL】Centos7 yum安装MySQL5.7.25

    在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 安装操作 下载并安装MySQL官方的Yum ...

  4. Centos7 yum安装 MySQL5.7.25

    扩展:在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 1 下载并安装MySQL官方的 Yum ...

  5. 在 CentOS7 上安装 MySQL5.7

    在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建 ...

  6. CentOS6.3 编译安装LAMP(3):编译安装 MySQL5.5.25

    所需源码包: /usr/local/src/MySQL-5.5.25/cmake-2.8.8.tar.gz /usr/local/src/MySQL-5.5.25/mysql-5.5.25.tar.g ...

  7. centos7编译安装MySQL5.7.9

    title: centos7编译安装MySQL5.7.9 date: 2016-05-12 16:20:17 tags: --- Centos7编译安装mysql5.7.9 mysql5.7有更好的性 ...

  8. [ 原创 ] Centos7.6安装Mysql5.7

    https://blog.csdn.net/shj_php/article/details/86712408 CentOS7下安装MySQL5.7安装与配置(YUM) http://blog.csdn ...

  9. CentOS7 离线安装mysql-5.7.16

    CentOS7 离线安装mysql-5.7.16 1 . 安装新版mysql前,需将系统自带的mariadb-lib卸载 [root@slave mytmp]# rpm -qa|grep mariad ...

随机推荐

  1. Linux 桌面玩家指南:12. 优秀的文本化编辑思想大碰撞(Markdown、LaTeX、MathJax)

    特别说明:要在我的随笔后写评论的小伙伴们请注意了,我的博客开启了 MathJax 数学公式支持,MathJax 使用$标记数学公式的开始和结束.如果某条评论中出现了两个$,MathJax 会将两个$之 ...

  2. 腾迅云CDN的使用

    一开始,我是想和七牛云一样,将腾迅云的对象存储作为网盘使用,不过在折腾的时间,搞不清楚腾迅云CDN的用法,最后看文档,看博客,大概了解了 这里讲两种用法,一种是结合对象存储,作一个静态网站或下载站,但 ...

  3. SpringBoot之GZip压缩,HTTP/2,文件上传,缓存配置

    1 设置应用端口以及context # HTTP Server port server.port=8080 # Make the application accessible on the given ...

  4. 【TensorFlow篇】--Tensorflow框架实现SoftMax模型识别手写数字集

    一.前述 本文讲述用Tensorflow框架实现SoftMax模型识别手写数字集,来实现多分类. 同时对模型的保存和恢复做下示例. 二.具体原理 代码一:实现代码 #!/usr/bin/python ...

  5. Vue.js-03:第三章 - 事件修饰符的使用

    一.前言 熟悉了 Vue 的指令系统后,在实际开发中,不可避免的会使用到对于事件的操作,如何处理 DOM 事件流,成为我们必须要掌握的技能.不同于传统的前端开发,在 Vue 中给我们提供了事件修饰符这 ...

  6. 【朝花夕拾】Android安全之(一)权限篇

    前言        从Android6.0开始,Android系统对权限的处理产生了很大的变化.如果APP运行的设备系统版本为Android6.0或更高,并且target在23或更高,那么danger ...

  7. java游戏开发杂谈 - java是什么

    java是一门编程语言, 它有三个开发平台:j2ee.j2se. j2me.(其实android也算一个了)      j2ee, 也就是web开发,比如网站.各类管理系统,主要是围绕数据库.网页等进 ...

  8. Spring Boot系列(一) Spring Boot准备知识

    本文是学习 Spring Boot 的一些准备知识. Spring Web MVC Spring Web MVC 的两个Context 如下图所示, 基于 Servlet 的 Spring Web M ...

  9. 105 - kube-scheduler源码分析 - predicate算法注册

    一.predicate注册过程 今天我们来聊聊predicate函数是怎么被注册进去的,也就是要执行的一堆predicate是怎么成为“选中的孩子”.  代码位置:pkg/scheduler/fact ...

  10. Prism定制Region控件

    并不是所有控件都可以被用作Region了吗?我们将Gird块的代码变成这样: <Grid> <ContentControl prism:RegionManager.RegionNam ...