Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to access MySQL database remotely in Ubuntu

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces how to access the MySQL database remotely in Ubuntu, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Commands for MySQL remote access

Format: mysql-h host address-u user name-p user password

Example:

Yanggang@host:~$ mysql-h292.168.1.11-uroot-p123456

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.11'

An error has occurred! Unable to connect to the remote MySQL

There are two ways for MySQL to connect to the database remotely:

Sock and TCP/IP, the former is faster than the latter, but it is limited to the same local machine, see

The above error is caused by no remote access

Solution:

1 on the target server (192.168.1.11), modify the my.cnf file of mysql:

Sudo vi / etc/mysql/my.cnf

2 comment out bind-address and block it from listening locally only

# bind-address = 127.0.0.1

3 start the MySQL service to make the modified configuration take effect, see

Sudo restart mysql

After configuring the data access permissions of the server, it is still not possible to access the MySQL database remotely.

This is because access to the database or table on the server has not yet been granted (GRANT)

4 on the server, log in to the MySQL database

Mysql-u root-p123456

5 Grant permissions to the database top800

Grant all privileges on top800.* to root@192.168.1.22 identified by '123456'

Flush privileges

6 MySQL on the server can now be accessed remotely

Mysql-h292.168.1.11-uroot-p123456

By default, you can only access information_schema and top800, where top800 is the database we gave permission in step 5

Knowledge expansion:

1 remove the user's access to the database on the server:

Revoke all privileges on top800.* from root@192.168.1.22 identified by '123456'

2 delete the user root on the server:

Delete from user where user='yanggang'

3 after the modification takes effect:

Flush privileges

On how to remotely access the MySQL database in Ubuntu to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report