一、安装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. Ocserv整合Radius认证

    目前社区主流SSL VPN有两个分支:openvpn和ocserv,通过官网和检索到的资料对比前者服务端比较强大,后者客户端和移动端支持更好,二者并不兼容: 另外前者商业化封装更好,偏向商业化,后者对 ...

  2. RTMP协议学习——从握手到播放

    从客户端发起播放请求,到rtrmp视频流开始播放,大致经过了握手->建立连接->创建流->播放这几步比较重要的步骤.下面我将结合wireshark的抓包,对其中的每个流程进行分析和学 ...

  3. 二分图--AcWing刷题

    S 城现有两座监狱,一共关押着 N 名罪犯,编号分别为 1∼N. 他们之间的关系自然也极不和谐. 很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突. 我们用"怨气值"( ...

  4. canvas实现动态替换人物的背景颜色

    起因 今天遇见一个特别有意思的小功能. 就是更换人物图像的背景颜色. 大致操作步骤就是:点击人物-实现背景颜色发生变化 将图片绘画到canvas画布上 我们需要将图片绘制到canvas画布上. 这样做 ...

  5. bool数据类型用法

    1 来自百度 1.bool为布尔型用作逻辑判断 2 2.bool只有一个字节 3 3.bool取值false和true,0为false,非0为true.(例如-1和2都是true). 4 4.bool ...

  6. (Good topic)双指针:判断子序列

    给定字符串 s 和 t ,判断 s 是否为 t 的子序列. 你可以认为 s 和 t 中仅包含英文小写字母.字符串 t 可能会很长(长度 ~= 500,000),而 s 是个短字符串(长度 <=1 ...

  7. 大白话说Python+Flask入门(三)

    写在前面 今天状态很不好,我发现学这部分知识的时候,会出现溜号或者注意力无法集中的情况. 我能想到的是,大概率是这部分知识,应该是超出了我现在的水平了,也就是说我存在知识断层了,整体感觉真的是一知半解 ...

  8. Keepalived+Nginx高可用案例(抢占式与非抢占式)

    (1)下载安装Keepalived源码包 Keepalived官网源码包下载地址 在服务器上解压 tar -xf keepalived-2.2.8.tar.gz 安装相关前置依赖 yum -y ins ...

  9. NPOI获取Excel文件里的形状/图片的坐标/锚点

    有个妹纸找我请教如何获取图片坐标,因此我到家后花了点时间,写了这份代码. 实测下来,可以正确获取 Excel 2003 版本的形状和图片这两种的坐标/锚点,以及 Excel 2007 版本的图片的坐标 ...

  10. 文心一言 VS 讯飞星火 VS chatgpt (151)-- 算法导论12.2 7题

    七.用go语言,对于一棵有 n 个结点的二叉搜索树,有另一种方法来实现中序遍历,先调用 TREE-MINIMUM 找到这棵树中的最小元素,然后再调用 n-1 次的 TREE-SUCCESSOR.证明: ...