简体   繁体   English

如何通过网络访问mysql?

[英]How do I access mysql over the network?

I have a development box and a development server. 我有一个开发盒和一个开发服务器。

I have some development tools on my development box with which I want to access MySQL residing on a development server. 我的开发盒上有一些开发工具,我想要访问开发服务器上的MySQL。

The development server was set up with XAMPP. 开发服务器是使用XAMPP设置的。

How do I make mysql available over the network? 如何通过网络提供mysql? What do I use for the host name? 我对主机名使用什么?

Thanks 谢谢

comment out the line: 注释掉这条线:

skip-networking -> #skip-networking

in the file: 在文件中:

/Applications/XAMPP/xamppfiles/etc/my.cnf

For accessing mysql of XAMPP over a network : 通过网络访问XAMPP的mysql:

-go to xammp directory XAMPP\\apache\\conf\\extra\\ -go到xammp目录XAMPP \\ apache \\ conf \\ extra \\

-open httpd-xampp.conf file and comment the Require local - 打开httpd-xampp.conf文件并注释Require local

 # # New XAMPP security concept # <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> #Require local ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </LocationMatch> 

-create the database in mysql and create new user with username and password with Host : % (any host) which will allow to connect the 'username'@'%' over the network - 在mysql中创建数据库并使用用户名和密码创建新用户:Host:%(任何主机),允许通过网络连接'username'@'%'

-open command prompt type ipconfig -open命令提示符键入ipconfig

now you can access the mysql at your ipaddress:3306 (3306 is default port for mysql) 现在你可以访问你的ipaddress上的mysql:3306(3306是mysql的默认端口)

Step 1: sudo /opt/lampp/lampp security set the mysql root password 第1步: sudo /opt/lampp/lampp security设置mysql root密码

Step 2: Access the database as sudo /opt/lampp/bin/mysql -u root -p then enter password of root user. 步骤2:以sudo /opt/lampp/bin/mysql -u root -p访问数据库,然后输入root用户的密码。

Step 3: Run the query run this query. 第3步:运行查询运行此查询。 GRANT ALL ON <db_name>.* TO <user_name>@'%' IDENTIFIED BY '<some_password>'; and then type exit . 然后键入exit

Step 4: Edit my.cnf (should be at /opt/lampp/etc/) and comment the line: 第4步:编辑my.cnf(应该在/ opt / lampp / etc /)并注释该行:

skip-networking 跳过网络

This line is uncommented when you run the Lampp security tool. 运行Lampp安全工具时,此行将被取消注释。

As

sudo nano /opt/lampp/etc/my.cnf , after comment as #skip-networking type control+x => y => enter sudo nano /opt/lampp/etc/my.cnf ,评论为#skip-networking type control+x => y => enter

NOTE: Of course, you should take the necessary steps to secure your databases properly after enabling network access. 注意:当然,您应该在启用网络访问后采取必要的步骤来正确保护数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM