Linux下Mysql的安装步骤
(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的安装步骤的更多相关文章
- Window/Linux下Mysql的安装步骤
Windows下Mysql安装教程 首先讲一下Windows环境下安装Mysql,我使用的安装包版本是mysql-8.0.26-winx64 下载地址:MySQL下载 1.点击上面的下载地址得到zip ...
- .Neter玩转Linux系列之六:Linux下MySQL的安装、配置、使用
一.Linux安装MySQL (1)下载安装包:https://dev.mysql.com/downloads/mysql/ (2)解压并安装 命令:tar zxvf 文件名 解压完成之后,重名一下文 ...
- linux下mysql的安装
一.下载 http://dev.mysql.com/downloads/mysql/ 选择对应的版本,这里选择“Linux-Generic” 以64位系统为例,这里需要下载如下两个文件: MySQL- ...
- linux下Mysql 的安装、配置、数据导入导出
MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),虽然功能未必很强大,但因它的免费开源而广受欢迎. 这次,接着上一篇<CentOs minimal安装和开发环境部署>,讲下L ...
- Linux中MySQL二进制安装步骤
MySQL二进制安装步骤 安装依赖环境 [root@node3 ~]# yum -y install libaio 将mysql-5.7.26-linux-glibc2.12-x86_64.tar.g ...
- linux 下mysql的安装,并设置必要的密码
首先,我使用的是redhat linux ,版本号为: [root@localhost init.d]# cat /proc/version Linux version - (bhcompile@po ...
- (0.2)linux下Mysql的安装配置与管理入门(目录篇)
本章学习内容: 1.基于Linux平台的Mysql项目场景介绍 1.1.互联网各类网站.购物网站.门户网站.博客系统.IDC,云平台,VPS,虚拟主机空间,论坛,嵌入式. 2.mysql数据库运行环境 ...
- 自学linux——13.Linux下mysql的安装
MySQL数据库 1.数据库联系 2.软件安装 (1)源码包安装 优点:开源,可以修改源代码编译安装,更加适合自己的系统,稳定高效 缺点:安装步骤较多,容易出错编译过程时间较长 常用语法: #tar ...
- Linux下mysql的安装和使用(C语言)
1 mysql的安装 我使用的ubuntu在线安装,非常简单,命令为: sudo apt-get install mysql-client mysql-server 2 mysql命令集合 网络太多了 ...
随机推荐
- [CB2]start up
1.更新源 From:http://cubie.cc/forum.php?mod=viewthread&tid=3054&extra= sudo emacs 打开/etc/apt/so ...
- 【Python】Webpy
http://webpy.org/install.zh-cn 官网学习,对于No socket could be created 一般是默认的8080端口已经被某些服务占用,可以换一个端口.
- Material design之Compatibility(适配)
Compatibility,为Android L版本和旧版本进行适配设置. 一:Material Theme适配 因为Material Theme只能在Android L的版本中使用,所以为了应用能在 ...
- JavaScript修改IE注册表
http://www.cnblogs.com/zmc/p/3373812.html <script type="text/javascript"> var obj = ...
- poj 2914(stoer_wanger算法求全局最小割)
题目链接:http://poj.org/problem?id=2914 思路:算法基于这样一个定理:对于任意s, t V ∈ ,全局最小割或者等于原图的s-t 最小割,或者等于将原图进行 Cont ...
- 提高PHP编程技术的方法
提高PHP编程技术的方法 下面介绍的是提高PHP编程技术的几种方法. 1.PHP标签 我知道有些人写PHP代码的时候喜欢用缩略标签<? ?>,但是这可不是个好习惯,因为缩略标签在有些服务器 ...
- 细说多线程之Thread VS Runnable
[线程创建的两种方式] [线程的生命周期] ● 就绪:创建了线程对象后,调用了线程的start(). (注意:此时线程只是进入了线程队列,等待获取CPU服务,具备了运行的条件,但并不一定已经开始运行了 ...
- 学习-go语言坑之for range
引用自 http://studygolang.com/articles/9701 go只提供了一种循环方式,即for循环,在使用时可以像c那样使用,也可以通过for range方式遍历容器类型如数组. ...
- 你不知道的Javascript(上卷)读书笔记之三 ---- 函数作用域与块作用域
1. 函数中的作用域 函数作用域的含义是指属于这个函数的全部变量都可以在整个函数范围内使用以及复用 2. 隐藏内部实现 函数经常使用于隐藏”内部实现”,可以把变量和函数包裹在一个函数的作用域中,然后用 ...
- 命名空间 <iostream>和<iostream.h> 由程序设计者命名的内存区域
namespace_百度百科 https://baike.baidu.com/item/namespace/1700121?fromtitle=命名空间 namespace即“命名空间”,也称“名称空 ...