一、安装MySQL

1. 删除Mysql 数据库

sudo apt autoremove --purge mysql-server-*
sudo apt remove mysql-server
sudo apt autoremove mysql-server
sudo apt remove mysql-common

2. 安装Mysql

sudo apt-get update #更新包
sudo apt install mysql-server-5.7

查看 MySQL 版本

sudo mysql -V

查看MySQL默认账号和密码

sudo cat /etc/mysql/debian.cnf

二、配置MySQL

sudo mysql_secure_installation
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N #2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入) #3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N #4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N #5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N #6
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 for No) : Y

三、查看mysql服务状态

systemctl status mysql.service

四、修改root账户认证方式

sudo cat /etc/mysql/debian.cnf  # 查看 Password 后面的密码
mysql -u debian-sys-maint -p #进入 mysql 命令模式 mysql> use mysql;
mysql> select user,host,authentication_string from user;
mysql> update mysql.user set authentication_string=password('密码') where user='root' and Host ='localhost';
mysql> update user set plugin='mysql_native_password'; //注意别更新错了,错了客户端工具就连不上了
mysql> select Host, User, plugin from user;
mysql> flush privileges;
mysql> quit; 

五、配置远程访问mysql

修改配置文件,注释掉bind-address = 127.0.0.1

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
:wq mysql -uroot -p mysql> use mysql;
mysql> update user set host='%' where user = 'root';
mysql> flush privileges;

#重启
sudo service mysql restart
#查看状态
systemctl status mysql.service

Ubuntu 安装 MySQL 5.7的更多相关文章

  1. ubuntu安装mysql

    好记性不如烂笔头,记录一下,ubuntu安装mysql的指令. 安装MySQL: sudo apt-get install mysql-server sudo apt-get install mysq ...

  2. ubuntu安装mysql后不能远程访问的方法

    ubuntu安装mysql后不能远程访问的方法1.mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassw ...

  3. Ubuntu 安装 Mysql 5.6 数据库

    Ubuntu 安装 Mysql 5.6 数据库 1)下载: mysql-5.6.13-debian6.0-x86_64.deb http://dev.mysql.com/downloads/mirro ...

  4. Ubuntu安装mysql之后,编译找不到头文件

    解决Ubuntu安装mysql之后找不到mysql.h问题   安装: sudo apt-get install libmysqlclient-dev   编译: gcc test.c -o test ...

  5. Linux Deploy Ubuntu安装MySQL

    一.在Android手机安装Linux 二.Ubuntu安装Mysql 建议在root用户上操作 sudo su 输入密码 (一)安装mysql 1. sudo apt-get install mys ...

  6. ubuntu安装mysql<服务器>

    服务器 阿里云服务器Ubuntu安装mysql 2014-08-22 21:52 |  coding云 |  7315次阅读 | 11条评论   这里首先吐槽一下阿里云,我作为公司的唯一懂服务器架设的 ...

  7. ubuntu安装mysql数据库方法

    ubuntu基于linux的免费开源桌面PC操作系统,十分契合英特尔的超极本定位,支持x86.64位和ppc架构.一个比较流行的Linux操作系统,不仅简单易用,而且和Windows相容性非常好.那么 ...

  8. ubuntu安装mysql并使用Navicat连接

    今天配置了一下自己的服务器,发现网上很多教程都有点老,而且不是很全.干脆就写一篇Ubuntu安装mysql,并用Navicat连接的全流程 一.安装mysql 1. sudo apt-get inst ...

  9. Ubuntu 安装mysql和简单操作

    http://www.cnblogs.com/zhuyp1015/p/3561470.html ubuntu上安装mysql非常简单只需要几条命令就可以完成. 1. sudo apt-get inst ...

  10. Ubuntu安装Mysql+Django+MySQLdb

    安装Mysql sudo apt-get install mysql-server mysql-client root@IdeaPad:/# mysql -u root -p Enter passwo ...

随机推荐

  1. 全网最详细4W字Flink全面解析与实践(下)

    本文已收录至GitHub,推荐阅读 Java随想录 微信公众号:Java随想录 原创不易,注重版权.转载请注明原作者和原文链接 承接上篇未完待续的话题,我们一起继续Flink的深入探讨 Flink S ...

  2. JAVA中的函数接口,你都用过吗

    公众号「架构成长指南」,专注于生产实践.云原生.分布式系统.大数据技术分享. 在这篇文章中,我们将通过示例来学习 Java 函数式接口. 函数式接口的特点 只包含一个抽象方法的接口称为函数式接口. 它 ...

  3. 总结---Django部分(二)

    Django中model的SlugField类型字段有什么用途? SlugField字段是将输入的内容中的空格都替换成'-'之后保存,Slug 是一个新闻术语,通常是某些东西的短标签.一个slug只能 ...

  4. Vite4+Typescript+Vue3+Pinia 从零搭建(4) - 代码规范

    项目代码同步至码云 weiz-vue3-template 要求代码规范,主要是为了提高多人协同和代码维护效率,结合到此项目,具体工作就是为项目配置 eslint 和 prettier. editorc ...

  5. 【python】大作业进度一 | 解析题目

    1.爬取生成txt文件(整本小说) 2.图形化界面的实现

  6. ElasticSearch索引生命周期策略配置(ES TTL)

    背景 有些索引数据作为临时数据存放,一段时间后我们希望索引可以自动过期删除,就是常说的TTL(Time To Live)机制 ElasticSearch索引数量过多会占用很多主分片和副本分片,最终导致 ...

  7. Android 图表开源库调研及使用示例

    原文地址: Android图表开源库调研及使用示例 - Stars-One的杂货小窝 之前做的几个项目都是需要实现图表统计展示,于是做之前调研了下,做下记录 概述 AAChartCore-Kotlin ...

  8. [ABC261G] Replace

    Problem Statement You are given two strings \(S\) and \(T\) consisting of lowercase English letters. ...

  9. Mybatis-Flex之QueryWrapper

    1.完整DQL语句 /** * 使用QueryWrapper构建超复杂SQL语句 */ @Test public void testQueryWrapper1() { QueryWrapper wra ...

  10. 后端程序员必会的前端知识-04:Vue3

    Vue 3 1. TypeScript 1) 动态类型的问题 前面我们讲过 js 属于动态类型语言,例如 function test(obj) { } obj 可能只是个字符串 test('hello ...