腾讯云安装MYSQL远程连接不上解决方案

推荐安装步骤博客,写的很详细,如果不会安装的话,可以根据安装步骤一直走。

Windows10下超详细Mysql安装_win10安装mysql-CSDN博客

修改 my.cnf或者my.ini 找到里面bind-address将bind-address = 127.0.0.1设置成bind-address = 0.0.0.0(设备地址)或者直接注释该行设置完重启mysql

mysql 8.0找不到my.ini配置文件

直接在bin文件夹同级目录,新建my.ini文件。
添加内容如下:

sql 复制代码
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\MySQL
datadir = D:\MySQL\data
port = 3306
server_id = 1
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

或者直接添加你需要修改的内容

sql 复制代码
[mysqld]
bind-address = 0.0.0.0
mysql没有开启远程连接

一、改表法。

可能是你的帐号不允许从远程登陆,只能在localhost登录。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改把host更改为"%"

a. bin/mysql -uroot -p密码

b. use mysql----->show tables;------>select host, user from user;

c. update user set host = '%' where user = 'root';

d. flush privileges;

二、授权法。

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果你想允许用户xiefei从ip为172.22.254.1的主机连接到mysql服务器,并使用123456作为密码 .

GRANT ALL PRIVILEGES ON *.* TO 'xiefei'@'172.22.254.1' IDENTIFIED BY '123456' WITH GRANT OPTION;

如果你在执行 GRANT 语句时遇到错误,可能是因为你的语法或者MySQL版本的问题。在MySQL 5.7及之后的版本中,GRANT 语句和 CREATE USER 语句是分开的,这意味着你不能直接在 GRANT 语句中创建用户并设置密码。你需要首先使用 CREATE USER 语句创建用户,然后设置密码,最后使用 GRANT 语句赋予权限。

-- 创建用户

CREATE USER 'root'@'%' IDENTIFIED BY 'smdc$#0510';

-- 刷新权限,使创建用户的操作立即生效

FLUSH PRIVILEGES;

-- 赋予用户所有权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

-- 再次刷新权限,使权限更改立即生效

FLUSH PRIVILEGES;

如果这些设置以后仍然无法实现连接的话,考虑是否将端口开放
相关推荐
爱考证的小刘1 小时前
MySQL OCP认证、Oracle OCP认证
mysql·oracle·oracle数据库·oracle认证·mysql自学·mysql题库·oracle学习
yjsstar1 小时前
数据库MySQL基础
数据库·mysql
TG_yunshuguoji1 小时前
亚马逊云渠道商:AWS 本地 SSD 缓存是什么?
缓存·云计算·aws
运维行者_1 小时前
AWS云服务故障复盘——从故障中汲取的 IT 运维经验
大数据·linux·运维·服务器·人工智能·云计算·aws
王道长服务器 | 亚马逊云1 小时前
AWS Systems Manager:批量服务器管理的隐藏利器
linux·网络·云计算·智能路由器·aws
桦02 小时前
[MySQL]数据类型
数据库·mysql
小小的木头人3 小时前
Docker MySQL 单主从及分表函数
mysql
小蜗的房子3 小时前
MySQL学习之SQL语法与操作
数据结构·数据库·经验分享·sql·mysql·学习方法·数据库开发
洲覆3 小时前
MySQL 索引原理
数据库·mysql
weixin_307779134 小时前
C#程序实现将MySQL的存储过程转换为Azure Synapse Dedicated SQL Pool的T-SQL存储过程
c#·自动化·云计算·运维开发·azure