介绍

MySQL 是一种开源数据库管理系统,通常作为流行的LAMP(Linux,Apache,MySQL,PHP / Python / Perl)堆栈的一部分安装。它使用关系数据库和SQL(结构化查询语言)来管理其数据。

安装的方式很简单:更新软件包索引,安装mysql-server软件包,然后运行附带的安全脚本即可。

sudo apt-get install mysql-server # 安装server

sudo apt-get isntall mysql-client  #安装client客户端

安装完成后mysql-server 会提示可以运行mysql_secure_installation。运行mysql_secure_installation会执行几个设置:

a)为root用户设置密码

b)删除匿名账号

c)取消root用户远程登录

d)删除test库和对test库的访问权限

e)刷新授权表使修改生效

通过这几项的设置能够提高mysql库的安全。建议生产环境中mysql安装这完成后一定要运行一次mysql_secure_installation,直接在终端中输入mysql_secure_installation即可开始配置。详细步骤请参看下面的命令:

stephen@stephen:~$ mysql_secure_installation

Securing the MySQL server deployment.

Enter passwordforuser root:

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwordswhichare

secure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key forNo: #是否设置密码检测插件,检测密码复杂度 ,根据自己需求设置

Using existing passwordforroot.

Change the passwordfor root ? ((Press y|Y for Yes, any other key forNo) : #是否更改密码

... skipping.

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account createdfor them. This is intended only fortesting, and tomakethe installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key forNo) : y #是否移除匿名账户 生产环境建议移除

Success.

Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow rootlogin remotely? (Press y|Y for Yes, any other key forNo) : y #是否禁止远程登录 根据实际情况设置

Success.

By default, MySQL comes with a database named'test'that

anyone can access. This is also intended onlyfortesting,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key forNo) : #删除测试数据库 直接回车

... skipping.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key forNo) : #是否重新加载权限表 直接回车

... skipping.

Alldone!

测试MySQL

安装过程中会提示设置密码什么的,注意设置了不要忘了,安装完成之后可以使用如下命令来检查是否安装成功:

sudo netstat -tap | grep mysql

通过上述命令检查之后,如果看到有mysql 的socket处于 listen 状态则表示安装成功。

按上边方式安装完成后,MySQL应该已经开始自动运行了。要测试它,请检查其状态。

systemctl status mysql.service #systemctl 用法 :https://linux.cn/article-5926-1.html

您将看到类似于以下内容的输出:

mysql.service - MySQL Community Server

Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en Active: active (running) since Wed 2016-11-23 21:21:25 UTC; 30min ago Main PID: 3754 (mysqld) Tasks: 28 Memory: 142.3M CPU: 1.994s CGroup: /system.slice/mysql.service └─3754 /usr/sbin/mysqld

如果MySQL没有运行,您可以启动它:

sudo systemctl mysql start

如果额外的检查,您可以尝试使用该 mysqladmin 工具连接到数据库,该工具是允许您运行管理命令的客户端。例如,该命令表示以 root(-u root)方式连接到 MySQL ,提示输入密码(-p)并返回版本。

mysqladmin -p -u root version

你应该看到类似的输出:

mysqladmin Ver 8.42 Distrib 5.7.16, for Linux on x86_64

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.

Server version 5.7.16-0ubuntu0.16.04.1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 30 min 54 sec

Threads: 1 Questions: 12 Slow queries: 0 Opens: 115 Flush tables: 1 Open tables: 34 Queries per second avg: 0.006

这意味着MySQL正在运行。

登陆mysql数据库可以通过如下命令:

mysql -u root -p

-u 表示选择登陆的用户名, -p 表示登陆的用户密码,上面命令输入之后会提示输入密码,此时输入密码就可以登录到mysql。

然后通过 show databases; 就可以查看当前的数据库。

我们选择 mysql数据库就行下一步操作,使用use mysql 命令,显示当前数据库的表单:show tables

ubuntu mysql 5.7_Ubuntu 16.04 上安装 MySQL 5.7 教程相关推荐

  1. ubuntu下mysql5.7安装教程_Ubuntu 16.04 上安装 MySQL 5.7 教程

    介绍 MySQL 是一种开源数据库管理系统,通常作为流行的LAMP(Linux,Apache,MySQL,PHP / Python / Perl)堆栈的一部分安装.它使用关系数据库和SQL(结构化查询 ...

  2. 如何在Ubuntu 16.04上使用MySQL 5.6配置Galera集群

    原作者:梅丽莎安德森  转载翻译:https://www.digitalocean.com/community/tutorials/how-to-configure-a-galera-cluster- ...

  3. ubuntu 16.04下安装mysql

    ubuntu 16.04下安装mysql 从官网下载mysql-apt-config_0.8.12-1_all.deb,下载地址为:https://dev.mysql.com/downloads/re ...

  4. 如何在 Ubuntu Linux 16.04上安装开源的 Discourse 论坛

    导读 Discourse 是一个开源的论坛,它可以以邮件列表.聊天室或者论坛等多种形式工作.它是一个广受欢迎的现代的论坛工具.在服务端,它使用 Ruby on Rails 和 Postgres 搭建, ...

  5. Ubuntu 16.04上安装SkyEye及测试

    说明一下,在Ubuntu 16.04上安装SkyEye方法不是原创,是来自互联网,仅供学习参考. 一.检查支持软件包 gcc, make, vim(optional), ssh, subversion ...

  6. 如何在Ubuntu 14.04上安装MySQL

    如何在Ubuntu 14.04上安装MySQL 介绍 MySQL是一个开源数据库管理系统,通常作为流行的LAMP(Linux,Apache,MySQL,PHP / Python / Perl)堆栈的一 ...

  7. 在 Ubuntu 16.04上安装 vsFTPd

    在 Ubuntu 16.04上安装 vsFTPd Ubuntu vsFTPd 关于 vsFTPd vsFTPd 代表 Very Secure File Transfer Protocol Daemon ...

  8. skyeye linux qt,Ubuntu 16.04上安装SkyEye及测试

    说明一下,在Ubuntu 16.04上安装SkyEye方法参考自互联网,仅供学习. 一.检查支持软件包 gcc, make, vim(optional), ssh, subversion binuti ...

  9. 如何在Ubuntu 16.04上安装Swift和Vapor

    翻译自:How to Install Swift and Vapor on Ubuntu 16.04 介绍 Swift是Apple开发的一种编程语言,特点是快,安全和现代化,它有一个支持语言的庞大社区 ...

最新文章

  1. 机器学习从零开始-常见算法手推pure python
  2. QQ 被曝搜集浏览器历史记录;饿了么回应骑手自焚;原锤子团队被合并暂停手机研发;| 极客头条...
  3. internal server error怎么解决_解决redis连接错误:MISCONF Redis is configured to save RDB
  4. 最长公共前缀 python_python 实现求解字符串集的最长公共前缀方法
  5. 100m网速测试软件,网速测试哦(100兆宽带wifi最佳设置)
  6. 数据结构与算法之栈的实现及逆波兰计算器简易版
  7. 计算机键盘上删除,电脑哪个是删除键
  8. 安装WPS后,word文件无法预览,无法右键新建的解决办法
  9. Linux DMA驱动构架分析
  10. 千人规模互联网公司研发效能成功之路
  11. Maven中scope标签详解
  12. E-R 图的不同表示方法(Chen 方法和 Crow‘s foot 方法)
  13. 众筹网站项目第七天之zTree树形结构实现(2)
  14. Java实现几分钟之后调度任务的定时器
  15. java中gc触发的条件_触发Full gc条件
  16. 美颜算法原理,推荐一个开源美颜算法工具
  17. 数学不好是原罪——凸优化学习笔记(个人学习记录汇总)
  18. 扫地机器人的轮子困住_扫地机器人防困住卡死的解决方案
  19. 从金蝶k3到金税盘_请问金碟K3财务软件具体操作流程?
  20. 测试注意力的游戏软件,专注力小游戏,传说最快的人只要7秒!测测你多久能完成……...

热门文章

  1. 斐波那契数列大数的压位c语言,HDU 1568 Fibonacci(大数前4位)
  2. 按顺序插入图片_MysqlInnodb特性之插入缓存
  3. java 建立一个graphics对象_java – 我应该显式处理Graphics对象吗?
  4. system类的 静态方法可以启动垃圾回收器。_跟小伟一起学习类加载机制
  5. 安卓手机管理_安卓手机:管理工具
  6. 一个合格的CloudNative应用:程序当开源软件编写,应用配置外置
  7. 高职高考全国计算机证书查询,2017年广东3+证书(高职高考)录取结果查询入口:附广东3+证书(高...
  8. php ftp login,关于php ftp_login()函数的10篇文章推荐
  9. Python正则表达式用法总结
  10. 零门槛人像转卡通、GIF表情包(赶快行动起来)