1、下载安装包
http://dev.mysql.com/downloads/mysql/#downloads
推荐下载通用安装方法的TAR包(http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar)。
http://dev.mysql.com/downloads/mysql/#downloads
推荐下载通用安装方法的TAR包(http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar)。
2.检查库文件是否存在,如有删除。
[root@localhost Desktop]$ rpm -qa | grep mysql
mysql-libs-5.1.52-1.el6_0.1.x86_64
[root@localhost Desktop]$ rpm -qa | grep mysql
mysql-libs-5.1.52-1.el6_0.1.x86_64
[root@localhost ~]# rpm -e mysql-libs-5.1.52.x86_64 --nodeps
[root@localhost ~]#
[root@localhost ~]#
3.检查mysql组和用户是否存在,如无创建。
[root@localhost ~]# cat /etc/group | grep mysql
mysql:x:490:
[root@localhost ~]# cat /etc/passwd | grep mysql
mysql:x:496:490::/home/mysql:/bin/bash
以上为默认存在的情况,如无,执行添加命令:
[root@localhost ~]#groupadd mysql
[root@localhost ~]#useradd -r -g mysql mysql
//useradd -r参数表示mysql用户是系统用户,不可用于登录系统。
[root@localhost ~]# cat /etc/group | grep mysql
mysql:x:490:
[root@localhost ~]# cat /etc/passwd | grep mysql
mysql:x:496:490::/home/mysql:/bin/bash
以上为默认存在的情况,如无,执行添加命令:
[root@localhost ~]#groupadd mysql
[root@localhost ~]#useradd -r -g mysql mysql
//useradd -r参数表示mysql用户是系统用户,不可用于登录系统。
4.解压TAR包,更改所属的组和用户
[root@localhost ~]# cd /usr/local/
[root@localhost local]# tar xvf mysql-5.7.12-linux-glibc2.5-x86_64.tar
[root@localhost local]# ls -l
total 1306432
-rwxr--r--. 1 root root 668866560 Jun 1 15:07 mysql-5.7.12-linux-glibc2.5-x86_64.tar
-rw-r--r--. 1 7161 wheel 638960236 Mar 28 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 7161 wheel 29903372 Mar 28 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz
[root@localhost local]# tar xvfz mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
[root@localhost local]# mv mysql-5.7.12-linux-glibc2.5-x86_64 mysql
[root@localhost local]# ls -l
total 1306436
drwxr-xr-x. 2 root root 4096 Dec 4 2009 bin
drwxr-xr-x. 2 root root 4096 Dec 4 2009 etc
drwxr-xr-x. 2 root root 4096 Dec 4 2009 games
drwxr-xr-x. 2 root root 4096 Dec 4 2009 include
drwxr-xr-x. 2 root root 4096 Dec 4 2009 lib
drwxr-xr-x. 3 root root 4096 Dec 2 14:36 lib64
drwxr-xr-x. 2 root root 4096 Dec 4 2009 libexec
drwxr-xr-x. 9 7161 wheel 4096 Mar 28 12:51 mysql
-rwxr--r--. 1 root root 668866560 Jun 1 15:07 mysql-5.7.12-linux-glibc2.5-x86_64.tar
-rw-r--r--. 1 7161 wheel 638960236 Mar 28 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 7161 wheel 29903372 Mar 28 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Dec 4 2009 sbin
drwxr-xr-x. 6 root root 4096 Dec 2 14:36 share
drwxr-xr-x. 2 root root 4096 Dec 4 2009 src
[root@localhost local]# chown -R mysql mysql/
[root@localhost local]# chgrp -R mysql mysql/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# tar xvf mysql-5.7.12-linux-glibc2.5-x86_64.tar
[root@localhost local]# ls -l
total 1306432
-rwxr--r--. 1 root root 668866560 Jun 1 15:07 mysql-5.7.12-linux-glibc2.5-x86_64.tar
-rw-r--r--. 1 7161 wheel 638960236 Mar 28 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 7161 wheel 29903372 Mar 28 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz
[root@localhost local]# tar xvfz mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
[root@localhost local]# mv mysql-5.7.12-linux-glibc2.5-x86_64 mysql
[root@localhost local]# ls -l
total 1306436
drwxr-xr-x. 2 root root 4096 Dec 4 2009 bin
drwxr-xr-x. 2 root root 4096 Dec 4 2009 etc
drwxr-xr-x. 2 root root 4096 Dec 4 2009 games
drwxr-xr-x. 2 root root 4096 Dec 4 2009 include
drwxr-xr-x. 2 root root 4096 Dec 4 2009 lib
drwxr-xr-x. 3 root root 4096 Dec 2 14:36 lib64
drwxr-xr-x. 2 root root 4096 Dec 4 2009 libexec
drwxr-xr-x. 9 7161 wheel 4096 Mar 28 12:51 mysql
-rwxr--r--. 1 root root 668866560 Jun 1 15:07 mysql-5.7.12-linux-glibc2.5-x86_64.tar
-rw-r--r--. 1 7161 wheel 638960236 Mar 28 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 7161 wheel 29903372 Mar 28 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Dec 4 2009 sbin
drwxr-xr-x. 6 root root 4096 Dec 2 14:36 share
drwxr-xr-x. 2 root root 4096 Dec 4 2009 src
[root@localhost local]# chown -R mysql mysql/
[root@localhost local]# chgrp -R mysql mysql/
[root@localhost local]# cd mysql/
5.安装和初始化数据库
[root@localhost mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2016-06-01 15:23:25 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-06-01 15:23:30 [WARNING] The bootstrap log isn't empty:
2016-06-01 15:23:30 [WARNING] 2016-06-01T22:23:25.491840Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-06-01T22:23:25.492256Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-06-01T22:23:25.492260Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
[root@localhost mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2016-06-01 15:23:25 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-06-01 15:23:30 [WARNING] The bootstrap log isn't empty:
2016-06-01 15:23:30 [WARNING] 2016-06-01T22:23:25.491840Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-06-01T22:23:25.492256Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-06-01T22:23:25.492260Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
----------------------
如果改变默认安装路径,则需要
1)/etc/my.cnf、/etc/init.d/mysqld中修改
basedir='/apps/mysql'
datadir='/apps/mysql/data'
2)创建ln
mkdir -p /usr/local/mysql/bin
ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld
----------------------
如果改变默认安装路径,则需要
1)/etc/my.cnf、/etc/init.d/mysqld中修改
basedir='/apps/mysql'
datadir='/apps/mysql/data'
2)创建ln
mkdir -p /usr/local/mysql/bin
ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld
----------------------
[root@localhost mysql]#
[root@localhost mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]# cp -a ./support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# cp -a ./support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# cd bin/
[root@localhost bin]# ./mysqld_safe --user=mysql &
[1] 2932
[root@localhost bin]# 2016-06-01T22:27:09.708557Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2016-06-01T22:27:09.854913Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@localhost bin]# ./mysqld_safe --user=mysql &
[1] 2932
[root@localhost bin]# 2016-06-01T22:27:09.708557Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2016-06-01T22:27:09.854913Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@localhost bin]# /etc/init.d/mysql restart
Shutting down MySQL..2016-06-01T22:27:50.498694Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended
SUCCESS!
Starting MySQL. SUCCESS!
[1]+ Done ./mysqld_safe --user=mysql
[root@localhost bin]#
//设置开机启动
[root@localhost bin]# chkconfig --level 35 mysql on
[root@localhost bin]#
Shutting down MySQL..2016-06-01T22:27:50.498694Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended
SUCCESS!
Starting MySQL. SUCCESS!
[1]+ Done ./mysqld_safe --user=mysql
[root@localhost bin]#
//设置开机启动
[root@localhost bin]# chkconfig --level 35 mysql on
[root@localhost bin]#
6.初始化密码
mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。
[root@localhost bin]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2016-06-01 15:23:25
,xxxxxR5H9
[root@localhost bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12
[root@localhost bin]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2016-06-01 15:23:25
,xxxxxR5H9
[root@localhost bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12
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.
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> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
7.添加远程访问权限
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host, user from user;
+-----------+-----------+
| host | user |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
+-----------+-----------+
mysql>quit
重启生效
service mysql stop
service mysql start
相关推荐
mysql5.7 安装脚本 mysql5.7 安装脚本 mysql5.7 安装脚本 mysql5.7 安装脚本
在Linux环境下安装MySQL 5.7是一个相对系统的过程,尤其对于初学者来说,可能需要一些指导。本教程将详述如何在Linux系统上逐步...记得在操作过程中,参照提供的“MySQL5.7安装步骤”文档,以确保每一步都正确无误。
### MySQL 5.7 安装步骤详解 #### 一、MySQL简介 MySQL是一个广泛使用的开源关系型数据库管理系统(RDBMS),它以其高性能、可靠性和易用性而闻名。MySQL由MySQL AB公司开发,目前已被Oracle公司收购。MySQL支持...
CentOS7 下安装 MySQL5.7 安装与配置 安装环境: CentOS7 64位 MINI 版 安装 MySQL5.7: 1. 配置 YUM 源:下载 MySQL 官网中的 YUM 源 RPM 安装包,安装 MySQL 源。 2. 安装 MySQL:使用 yum 安装 MySQL 服务器。 3...
**一、Windows上的MySQL 5.7安装** 1. 访问MySQL官方网站下载页面,选择适用于Windows的MySQL Community Server 5.7安装包。 2. 运行安装程序,选择"Custom"安装类型以自定义安装路径。 3. 在组件选择界面,确保...
mysql5.7安装教程+mysql5.7镜像安装+mysql学习+mysql5.7镜像包 mysql5.7安装教程+mysql5.7镜像安装+mysql学习+mysql5.7镜像包 mysql5.7安装教程+mysql5.7镜像安装+mysql学习+mysql5.7镜像包 mysql5.7安装教程+mysql...
### MySQL 5.7 安装与配置详细指南 #### 一、MySQL 5.7 安装概述 MySQL 5.7 是一款非常流行的开源关系型数据库管理系统,广泛应用于各种规模的应用程序开发中。本篇文章将详细介绍如何安装 MySQL 5.7,并提供一些...
MySQL5.7手动编译安装详细步骤;可根据自己的喜欢任意选择安装路径,配置文件存放路径等。 温馨提示:本安装步骤只在centos7环境下测试过,其余环境暂未测试,如有问题,欢迎留言告知,后续会尽快完善其他环境的编译...
### MySQL 5.7 安装操作指南 MySQL 5.7 是一款广泛使用的开源关系型数据库管理系统。本文档将详细介绍 MySQL 5.7 的安装步骤,并解释每个步骤的重要性和实施细节。 #### 1. 下载安装包 首先,访问 MySQL 官方下载...
Mysql5.7安装配置.md
资源名称:Mysql5.7安装教程内容简介: MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的。如果是msi格式的可以直接点击安装,按照它给出的安装提示进行安装(相信大家的英文可以看懂英文提示),一般MySQL...
mysql5.7镜像;mysql5.7镜像;mysql5.7镜像;mysql5.7镜像
### Linux安装MySQL 5.7详细步骤 #### 一、准备环境 在开始安装MySQL 5.7之前,确保你的Linux系统已经准备就绪。这包括但不限于安装必要的依赖包、预留足够的磁盘空间等。 #### 二、挂载数据盘 如果计划将MySQL...
鉴于题目要求我们关注于Linux环境下的安装教程,以下将针对Linux环境下的MySQL 5.7安装进行详细解析。 ### Linux上MySQL 5.7安装教程 #### 一、安装前准备 1. **确认系统兼容性**:确保您的Linux发行版支持MySQL ...
下面我们将详细探讨 MySQL 5.7 的审计插件及其安装步骤。 ### 一、审计插件概述 MySQL 审计插件(audit_log_plugin)提供了对数据库服务器事件的详细日志记录功能。这些事件包括用户连接、断开连接、SQL语句执行、...
"Mysql 5.7 安装步骤详解" 在 Linux 环境中安装 Mysql 5.7 需要经过多个步骤,包括下载安装包、检查库文件、创建 mysql 组和用户、解压 TAR 包、更改所属的组和用户等。本文将详细介绍 Mysql 5.7 安装步骤,帮助...
mysql5.7.16安装脚本,一键安装,安全可靠,方便快捷。