(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. mui 子页面切换父页面底部导航

    在父页面中新增方法: function switchTab(tab){ plus.webview.hide(activeTab); activeTab= tab; plus.webview.show( ...

  2. ChemDraw在苹果电脑上能不能用

    很多ChemDraw 15.1 Pro用户都Windows操作系统用户,近年来随着苹果公司的影响力越来越大,使用苹果电脑的朋友越来越多.一些ChemDraw用户可能会使用苹果电脑,因此特别的关注在苹果 ...

  3. java 环境变量classpath的作用

    http://www.cnblogs.com/xwdreamer/archive/2010/09/08/2297098.html http://www.cnblogs.com/panxuejun/p/ ...

  4. C语言必掌握知识点

    个人总结,学c的赶快看 1-.++a 和 a++ 的差别:           ++a  先加在赋值  a++ 先赋值在加  后者赋给变量b的值为a而不是a+1后的值 2-.按位与  同为1时为1,其 ...

  5. WebService之XFire和SOAP实例(基于JAVA)

    开发环境:jdk1.6 + Tomcat7 + MyEclipse10 源码下载地址张贴在文章最后面:首先是使用WSDL协议实现:这里使用XFire XFire一个免费.开源的SOAP框架,它构建了P ...

  6. 全局安装了express框架,但是无法使用express指令的问题

    错误截图: 产生这个错误的原因是:我安装的是express4版本,需要安装express-generator才能使用express命令 将express-generator安装后就都解决了:

  7. Oracle 数据库的组成(instance+database)

    Oracle服务器是一种对象关系数据库管理系统,它为信息管理提供开放.综合.集成的方法. Oracle服务器中有多种进进程.内存结构和文件: Oracle服务器由一个Oracle实例和一个Oracle ...

  8. Java程序员面试题集(1-50

    下面的内容是对网上原有的Java面试题集及答案进行了全面修订之后给出的负责任的题目和答案,原来的题目中有很多重复题目和无价值的题目,还有不少的参考答案也是错误的,修改后的Java面试题集参照了JDK最 ...

  9. 修改hosts文件不起作用

    今天遇到个很奇怪的问题,在hosts文件里添加了一些域名指向后,发现根本没起作用,后来还发现个细节,就是hosts文件左下角有个小锁的标志,开始以为是杀毒软件之类的把他锁了.可是没找到在哪里有相关操作 ...

  10. ubuntu su failure when password was right

    https://blog.csdn.net/u013066244/article/details/52694540