如何用sqlyog实现远程连接mysql

2024-12-03 11:05:44
推荐回答(3个)
回答1:

通过SQLyog来连接MySQL

(1) 执行File→New connection菜单命令。将打开连接提示对话框。单击New按钮,将创建一个新的连接,给新连接定义一个名字"zyj"

(2) 单击OK按钮,在MySQL的设置窗体输入相关的数据。注意Port是安装MySQL时默认的访问端口,如果安装时未修改,则默认值为3306。

(3) 当单击Test Connection按钮时,将弹出Connection Info对话框。如果提示连接失败,请确定输入的用户名、密码或端口号是否正确。

(4) 当单击"确定"按钮后,就完成了SQLyog与MySQL的连接。接下来就可以通过SQLyog来进行MySQL的相关操作了

回答2:

  1,sqlyog客户端,用root用户远程链接mysql时,提示“访问被拒绝”,在网上搜索了一下原因。  原来是mysql没有授权其远程链接,所以你只能在客户端里面链接。  怎么解决呢?  原表数据  mysql> use mysql  mysql> select Host,User,Password from user ;  +---------------+---------+-------------------------------------------+  | Host | User | Password |  +---------------+---------+-------------------------------------------+  | localhost | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | www | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | 127.0.0.1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | ::1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  创建一个新用户  格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by "用户密码";  grant select,update,insert,delete on *.* to komiles@123.4.56.89 identified by "komiles1234";  执行完上面语句后,再执行  mysql> select Host,User,Password from user ;  +---------------+---------+-------------------------------------------+  | Host | User | Password |  +---------------+---------+-------------------------------------------+  | localhost | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | www | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | 127.0.0.1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | ::1 | root | *DEA65ABECC50A1FEBD9C0D0D9045E0DDB312F38F |  | 123.4.56.89 | komiles | *50663F1ECEAB844897BC272EC1AE7E83F442F649 |  +---------------+---------+-------------------------------------------+  此时,就可以用你刚才创建的用户进行远程访问了。  以下是转载http://www.cnblogs.com/smallstone/archive/2010/04/29/1723838.html  2、实现远程连接(授权法)  将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。  update user set host = ’%’ where user = ’root’;  将权限改为ALL PRIVILEGES  mysql> use mysql;  Database changed  mysql> grant all privileges on *.* to root@'%' identified by "root";  Query OK, 0 rows affected (0.00 sec)  mysql> select host,user,password from user;  +--------------+------+-------------------------------------------+  | host | user | password |  +--------------+------+-------------------------------------------+  | localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |  | 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |  | % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |  +--------------+------+-------------------------------------------+  3 rows in set (0.00 sec)  这样机器就可以以用户名root密码root远程访问该机器上的MySql.  3、实现远程连接(改表法)  use mysql;  update user set host = '%' where user = 'root';  这样在远端就可以通过root用户访问Mysql.

回答3:

$CFG->dbtype = 'mysqli'; // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'moodle'; // database name, eg moodle
$CFG->dbuser = 'root'; // your database username
$CFG->dbpass = '123456'; // your database password
$CFG->prefix = 'mdl_'; // prefix to use for all table names