(1)、下载安装包

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar

[root@localhost local]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar
---- ::-- https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:... connected.
HTTP request sent, awaiting response... Found
Location: https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar [following]
---- ::-- https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar
Resolving cdn.mysql.com (cdn.mysql.com)... 23.36.193.224
Connecting to cdn.mysql.com (cdn.mysql.com)|23.36.193.224|:... connected.
HTTP request sent, awaiting response... OK
Length: (643M) [application/x-tar]
Saving to: 鈥榤ysql-5.7.-linux-glibc2.-x86_64.tar鈥 %[========================================================================>] ,, 191KB/s in 53m 15s -- :: ( KB/s) - 鈥榤ysql-5.7.-linux-glibc2.-x86_64.tar鈥saved [/] [root@localhost local]# ls
bin etc games include lib lib64 libexec mysql-5.7.-linux-glibc2.-x86_64.tar sbin share src
[root@localhost local]# mv mysql-5.7.-linux-glibc2.-x86_64.tar src/

(2)、解压到/usr/local/下,重命名为mysql

[root@localhost src]# tar xvf mysql-5.7.-linux-glibc2.-x86_64.tar -C /usr/local/
mysql-5.7.-linux-glibc2.-x86_64.tar.gz
mysql-test-5.7.-linux-glibc2.-x86_64.tar.gz
[root@localhost src]# cd ../
[root@localhost local]# ls
bin include libexec sbin
etc lib mysql-5.7.-linux-glibc2.-x86_64.tar.gz share
games lib64 mysql-test-5.7.-linux-glibc2.-x86_64.tar.gz src
[root@localhost local]# tar xvf mysql-5.7.-linux-glibc2.-x86_64.tar.gz
mysql-5.7.-linux-glibc2.-x86_64/bin/myisam_ftdump
mysql-5.7.-linux-glibc2.-x86_64/bin/myisamchk
mysql-5.7.-linux-glibc2.-x86_64/bin/myisamlog
mysql-5.7.-linux-glibc2.-x86_64/bin/myisampack
.
.
.
[root@localhost local]# mv mysql-5.7.-linux-glibc2.-x86_64 mysql
[root@localhost local]# ls
bin games lib libexec mysql-5.7.-linux-glibc2.-x86_64.tar.gz sbin src
etc include lib64 mysql mysql-test-5.7.-linux-glibc2.-x86_64.tar.gz share

 (3)、在mysql下创建数据库文件目录

[root@localhost local]# mkdir mysql/data

(4)、创建mysql用户组和用户,并对mysql目录设置用户组和用户

[root@localhost local]# groupadd mysql
[root@localhost local]# useradd mysql -g mysql
[root@localhost local]# cd mysql/
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .

(5)、安装初始化

由于MySQL运行需要libaio库,所以需要运行以下命令进行安装

[root@localhost mysql]# yum install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.shu.edu.cn
* updates: mirrors.shu.edu.cn
Package libaio-0.3.-.el7.x86_64 already installed and latest version
Nothing to do
[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
-- :: [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
-- :: [WARNING] The bootstrap log isn't empty:
-- :: [WARNING] --02T11::.811985Z [Warning] --bootstrap is deprecated. Please consider using --initialize instead
--02T11::.819990Z [Warning] Changed limits: max_open_files: (requested )
--02T11::.820064Z [Warning] Changed limits: table_open_cache: (requested )
[root@localhost support-files]# ./mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
SUCCESS!

(6)、登录mysql

此版本最新版不许空密码登录,实际上有个初始化密码保存在/root/.mysql_secret这个文件里面,用这个密码第一次登录后,再修改密码。

[root@localhost support-files]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at -- ::
B#ipur,uyB>a
[root@localhost support-files]# mysql -uroot -p
-bash: mysql: command not found
[root@localhost support-files]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost support-files]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. Copyright (c) , , 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>

改mysql的root密码,新密码在此为'123456'

mysql> set password=password('');
Query OK, rows affected, warning (0.00 sec)

(7)、复制配置文件

查看support-files文件夹的内容,发现并没有my-default.cnf默认的配置文件,如果没有默认的配置文件,需要手动创建一个my-default.cnf配置文件。

[root@localhost support-files]# ls -la
total
drwxr-xr-x. mysql mysql Aug : .
drwxr-xr-x. mysql mysql Aug : ..
-rw-r--r--. mysql mysql Jun : magic
-rwxr-xr-x. mysql mysql Jun : mysqld_multi.server
-rwxr-xr-x. mysql mysql Jun : mysql-log-rotate
-rwxr-xr-x. mysql mysql Jun : mysql.server

从网上找了一个配置文件,如下,上传到supp-files文件夹中,当然这个配置文件可以根据需要自行修改

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. [mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port =
socket = /tmp/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
character-set-server=utf8
back_log =
max_connections =
max_connect_errors =
table_open_cache =
#binlog_cache_size = 4M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size =
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len =
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time =
server_id=
innodb_buffer_pool_size = 1G
innodb_thread_concurrency =
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_lock_wait_timeout =
innodb_file_per_table = on [mysqldump]
quick
max_allowed_packet = 32M [mysql]
no-auto-rehash
connect_timeout= [client]
port=
socket = /tmp/mysql.sock
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
[root@localhost support-files]#
[root@localhost support-files]# ./mysql.server start
Starting MySQL. SUCCESS!

(8)、将mysqld服务加入开机自启动项

首先需要将support-files/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。

[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# ls -la /etc/init.d/
total
drwxr-xr-x. root root Aug : .
drwxr-xr-x. root root Jul : ..
-rw-r--r--. root root Jan functions
-rwxr-xr-x. root root Aug : mysqld
-rwxr-xr-x. root root Jan netconsole
-rwxr-xr-x. root root Jan network
-rw-r--r--. root root Apr : README

通过chkconfig命令将mysqld服务加入到自启动服务项中

[root@localhost support-files]# chkconfig --add mysqld

查看是否添加成功

[root@localhost support-files]# chkconfig --list

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 :off :off :on :on :on :on :off
netconsole :off :off :off :off :off :off :off
network :off :off :on :on :on :on :off

(9)、重启系统,mysqld就会自动启动了

检查是否启动

[root@localhost ~]# netstat -anp|grep mysqld
tcp6 ::: :::* LISTEN /mysqld
unix [ ACC ] STREAM LISTENING /mysqld /tmp/mysql.sock

如果不想重新启动,那可以直接手动启动。

[root@localhost ~]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

 (10)、设定远程登录mysql

mysql> use mysql;
Database changed
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)
mysql> grant all privileges on *.* to root@'%' identified by '';
Query OK, rows affected, warning (0.00 sec)
mysql> flush privileges;
Query OK, rows affected (0.01 sec)
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)

Linux下Mysql的安装步骤的更多相关文章

  1. Window/Linux下Mysql的安装步骤

    Windows下Mysql安装教程 首先讲一下Windows环境下安装Mysql,我使用的安装包版本是mysql-8.0.26-winx64 下载地址:MySQL下载 1.点击上面的下载地址得到zip ...

  2. .Neter玩转Linux系列之六:Linux下MySQL的安装、配置、使用

    一.Linux安装MySQL (1)下载安装包:https://dev.mysql.com/downloads/mysql/ (2)解压并安装 命令:tar zxvf 文件名 解压完成之后,重名一下文 ...

  3. linux下mysql的安装

    一.下载 http://dev.mysql.com/downloads/mysql/ 选择对应的版本,这里选择“Linux-Generic” 以64位系统为例,这里需要下载如下两个文件: MySQL- ...

  4. linux下Mysql 的安装、配置、数据导入导出

    MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),虽然功能未必很强大,但因它的免费开源而广受欢迎. 这次,接着上一篇<CentOs minimal安装和开发环境部署>,讲下L ...

  5. Linux中MySQL二进制安装步骤

    MySQL二进制安装步骤 安装依赖环境 [root@node3 ~]# yum -y install libaio 将mysql-5.7.26-linux-glibc2.12-x86_64.tar.g ...

  6. linux 下mysql的安装,并设置必要的密码

    首先,我使用的是redhat linux ,版本号为: [root@localhost init.d]# cat /proc/version Linux version - (bhcompile@po ...

  7. (0.2)linux下Mysql的安装配置与管理入门(目录篇)

    本章学习内容: 1.基于Linux平台的Mysql项目场景介绍 1.1.互联网各类网站.购物网站.门户网站.博客系统.IDC,云平台,VPS,虚拟主机空间,论坛,嵌入式. 2.mysql数据库运行环境 ...

  8. 自学linux——13.Linux下mysql的安装

    MySQL数据库 1.数据库联系 2.软件安装 (1)源码包安装 优点:开源,可以修改源代码编译安装,更加适合自己的系统,稳定高效 缺点:安装步骤较多,容易出错编译过程时间较长 常用语法: #tar  ...

  9. Linux下mysql的安装和使用(C语言)

    1 mysql的安装 我使用的ubuntu在线安装,非常简单,命令为: sudo apt-get install mysql-client mysql-server 2 mysql命令集合 网络太多了 ...

随机推荐

  1. js压缩 uglify

    grunt-contrib-uglify uglify是一个文件压缩插件,项目地址:https://github.com/gruntjs/grunt-contrib-uglify 本文将以一个DEMO ...

  2. 编写高质量代码--改善python程序的建议(一)

    原文发表在我的博客主页,转载请注明出处! 初衷 python是一个入门十分容易的编程语言,但是想要写好python却是一件不容易的事情,如果不是专业使用python的人,只是将python作为一个脚本 ...

  3. 51NOD 1013(3的幂的和)

    题目链接:传送门 题目大意:求(3^0+3^1+3^2+3^3+...+3^n)%1e9的值 题目思路:乘法逆元裸题 #include <iostream> #include <cs ...

  4. 170228、Linux操作系统安装ELK stack日志管理系统--(1)Logstash和Filebeat的安装与使用

    安装测试环境:Ubuntu 16.04.2 LTS 前言 (1)ELK是Elasticsearch,Logstash,Kibana 开源软件的集合,对外是作为一个日志管理系统的开源方案.它可以从任何来 ...

  5. 160809、tomcat中配置多个域名及将tomcat配置成系统服务

    本地测试用的(注意红色部分) 第一步.自己的windows电脑,在c盘中有个hosts文件(搜索一下),做以下修改(其中127.0.0.1是本机地址,192.1638.10.139是我虚拟机中linu ...

  6. 解决Sublime_Text不能安装插件的方法

    channel.json文件请到下面的网址下载: http://download.csdn.net/detail/xiaoming11654187/9866213 1.先将channel.json文件 ...

  7. cygwin简介,安装及卸载(体验UNIX & Linux环境)

    对于爱好者或初学者来说,为了体验UNIX & Linux环境,去安装虚拟机或双系统稍显麻烦,cygwin是一个很好的选择 具/原料   安装windows的电脑一台(可以联网) 法/步骤   ...

  8. 《挑战程序设计竞赛》2.5 最短路 AOJ0189 2249 2200 POJ3255 2139 3259 3268(5)

    AOJ0189 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0189 题意 求某一办公室到其他办公室的最短距离. 多组输入,n表示 ...

  9. Contos更换python版本

    1.查看版本 #python -VPython 2.6.6 2.安装前准备,安装相关库#yum install gcc gcc-c++ autoconf automake#yum install op ...

  10. express, mocha, supertest,istanbul

    引子 有群友问到Express怎么做 单元测试/覆盖率测试,这是上篇所遗漏的,特此补上 Express Web测试 做 Express Web 测试首先要面对的问题是在哪端进行测试: 客户端的请求响应 ...