mysql怎么样开通外网IP可连接

mysql怎么样开通外网IP可连接,第1张

设置mysql服务允许外网访问,修改mysql的配置文件,有的是myini,有的是mycnflinux
1:设置mysql的配置文件
/etc/mysql/mycnf
找到 bind-address =127001 将其注释掉;//作用是使得不再只允许本地访问;
重启mysql:/etc/initd/mysql restart;
2:登录mysql数据库:mysql -u root -p
mysql> use mysql;
查询host值:
mysql> select user,host from user;
如果没有"%"这个host值,就执行下面这两句:
mysql> update user set host='%' where user='root';
mysql> flush privileges;
或者也可以执行:
mysql>grand all privileges on to root@'%' identifies by ' xxxx';
其中 第一个表示数据库名;第二个表示该数据库的表名;如果像上面那样 的话表示所有到数据库下到所有表都允许访问;
‘%':表示允许访问到mysql的ip地址;当然你也可以配置为具体到ip名称;%表示所有ip均可以访问;
后面到‘xxxx'为root 用户的password;
举例:
任意主机以用户root和密码mypwd连接到mysql服务器
mysql> GRANT ALL PRIVILEGES ON TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> flush privileges;
IP为1921681102的主机以用户myuser和密码mypwd连接到mysql服务器
mysql> GRANT ALL PRIVILEGES ON TO 'myuser'@'1921681102' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> flush privileges;

phpMyAdmin 尝试连接到 MySQL 服务器,但服务器拒绝连接。您应该检查配置文件中的主机、用户名和密码是设置错误造成的,解决方法为:

1、在电脑中打开mysql workbench程序。

2、在workbench的初始界面,点击“+”图标添加一个mysql连接,如图所示。

3、在d出的对话框中输入具体的mysql连接信息,如图所示。

4、连接到mysql服务器的数据库后,点击左边菜单中的“Server Status”,如图所示。

5、在打开的新界面中,找到“Configuration File”,这个就是mysql服务器配置文件地址。

你先运行 CMD
然后 进入到那个 mysql 的目录下, 再运行。
例如:
D:\>cd mys
D:\mysql-5150-win32>cd bin
D:\mysql-5150-win32\bin>mysql
Welcome to the MySQL monitor Commands end with ; or \g
Your MySQL connection id is 1
Server version: 5150-community MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates All rights reserved
This software comes with ABSOLUTELY NO WARRANTY This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help Type '\c' to clear the current input statement
mysql> use test
Database changed


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/12648303.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-27
下一篇 2023-05-27

发表评论

登录后才能评论

评论列表(0条)

保存