Ubuntu18简单安装配置MySQL远程访问

简介

Mysql做为一个开源的数据管理系统,经常用于LAMP或者LNMP集成安装包(Linux、Apache\Nginx、MySQL、

PHP)的一部分进行安装。使用它的关系数据以及SQL查询语句来管理数据库,这里我们演示一单独如何使用Ubuntu18

安装Mysql并进行简单的配置。

 

教程

安装Mysql

先来更新一下apt软件包

apt update

安装MySQL,默认安装的是apt软件包当中的最新版本

apt install mysql-server

- ubuntu18mysql01

 

配置Mysql

进行配置

mysql_secure_installation

配置时参数

#验证密码插件
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N 

#设置新密码
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 

#是否允许从本地登录
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) : Y 

#是否删除默认情况MySQL带有一个名为“test”的数据库
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 (我的选项)

#是否重新加载所做的更改立即生效
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

- ubuntu18mysql02

使用root用户进入

mysql -uroot -p

- ubuntu18mysql03

其中root@localhos,localhost就是本地访问,配置成%就是所有主机都可连接

GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";

- ubuntu18mysql04

 

配置mysql远程访问

Ubuntu下缺省是指允许本地访问MySQL,这里我们就需要进行配置远程访问让其他机器也可以访问

新建数据库做为远程用户使用

CREATE DATABASE ivpsr;

创建用户ivpsr(密码654321) 并允许ivpsr用户可以从任意机器上登入mysql的ivpsr数据库

GRANT ALL PRIVILEGES ON ivpsr.* TO ivpsr@"%" IDENTIFIED BY "654321"; 

后面可以使用workbench进行连接mysql数据库

上一篇 教你GoDaddy域名DNS解析设置教程
下一篇 DreamIT Host:全场5折特惠,新西兰/澳大利亚VPS,低至3.29美元/月,1核2G内存/50G SSD硬盘/1T流量 带DDOS防御

投稿邮箱:
[email protected] (投稿详情)

TG订阅频道:
t.me/ivpsr_news 网站最新内容推送

TG交流群:
(点击加入) 用户交流

文章列表
1
VPS 优化技巧:为 Ubuntu 添加 Swap 扩展内存,提升 Docker 和编译稳定性
VPS 优化技巧:为 Ubuntu 添加 Swap 扩展内存,提升 Docker 和编译稳定性
2
linux系统debian10开启使用root用户登录ssh简明方法
linux系统debian10开启使用root用户登录ssh简明方法
3
香港服务器云途预售600元/月,Gold 6248/64G/1TSSD/40T流量/2Gbps带宽
香港服务器云途预售600元/月,Gold 6248/64G/1TSSD/40T流量/2Gbps带宽
4
LOCVPS香港VPS特惠:仅需100元/年,2GB内存起,优化大陆网络
LOCVPS香港VPS特惠:仅需100元/年,2GB内存起,优化大陆网络
5
Linux简单搭建socks5入门教程Dante SOCKS Proxy
Linux简单搭建socks5入门教程Dante SOCKS Proxy
6
Digital-VM低至5.6美元/月的日本东京简单测评,带你了解日本机房的Digital-VM怎么样
Digital-VM低至5.6美元/月的日本东京简单测评,带你了解日本机房的Digital-VM怎么样
7
突发国内著名梯子软件Clash for windows删库了
突发国内著名梯子软件Clash for windows删库了
8
iWebFusion AMD EPYC VPS 85折促销,10Gbps带宽/5T流量/2核/4g内存,洛杉矶/拉斯维加斯/北卡等6个机房低至$7.97/月
iWebFusion AMD EPYC VPS 85折促销,10Gbps带宽/5T流量/2核/4g内存,洛杉矶/拉斯维加斯/北卡等6个机房低至$7.97/月
9
桔子数据:五一特别优惠码,全场5折VPS,月付低至14元,洛杉矶CUVIP,三网CN2 GIA,日本CN2直连
桔子数据:五一特别优惠码,全场5折VPS,月付低至14元,洛杉矶CUVIP,三网CN2 GIA,日本CN2直连
10
debian9、10快速更换阿里云源和其他的源
debian9、10快速更换阿里云源和其他的源