Home > Database > Mysql Tutorial > mysql的局域网连接

mysql的局域网连接

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:39:38
Original
1451 people have browsed it

在Ubuntu上安装好mysql服务器后,需要在局域网里通过jdbc进行访问,开始怎么都不成功。 后来查找了一些资料,做了如下修改。 1.默认情况下, 使用MySQL只能通过本机Socket连接,需要修改my.cnf(在/etc/mysql下), 注释 #bind-address = 127.0.0.1 2.授权从任何

在Ubuntu上安装好mysql服务器后,需要在局域网里通过jdbc进行访问,开始怎么都不成功。

后来查找了一些资料,做了如下修改。

1.默认情况下,使用MySQL只能通过本机Socket连接,需要修改my.cnf(在/etc/mysql下),注释

#bind-address   = 127.0.0.1
Copy after login
2.授权从任何主机连接到mysql服务器

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;   
Copy after login
flush privileges;
Copy after login
然后重启mysql服务器

sudo service mysql restart


可以通过:mysql -h192.168.1.102 -uroot -p 进行测试

在java中连接的url为 jdbc:mysql:ip_addr:3306/db_name.





Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template