How to allow remote connection in MySql To achieve this goal, two things need to be done
Activate user permissions First log in to the MySQL server //You can log in to mysql directly without using spaces -u username -p password mysql> use mysql mysql> select user, host from user; Rendering After executing the code, you will see all users and their corresponding hosts The host refers to the IP address that is allowed to be accessed, and % means any IP. Of course, if it is your local server, you can also configure it to a local IP. Users can use SQL statements to set host to all //Update the host. Here you need to select an existing user and host. //In the user table, user and host together are the primary key, so they cannot be repeated. As shown in the figure above, if you only query the root update, an error will be reported mysql> update user set host = '%' where user = 'root' and host = 'localhost' This modifies the permissions of an existing user. Or You can choose to recreate new user permissions. // Of course, you can also specify some permissions, such as read-only mysql>GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%' IDENTIFIED BY 'newpassword' WITH GRANT OPTION; The following is a list of global permissions: Global management permissions: FILE: Read and write files on the MySQL server. Database/table/column permissions: ALTER: Modify existing data tables (such as adding/deleting columns) and indexes. Special permissions: ALL: Allows you to do anything (same as root). Unbind address I have enabled the permission before, but the local binding has not been released, so I still cannot connect to the server database through the command line locally. Later, I read some information and learned about address binding. My server is Ubuntu Server and I installed mysql via apt-get. The location of the configuration file is as follows: /etc/mysql/my.conf If it is a Windows server, it should be the my.ini file, and you need to find it in the location where MySQL is installed. From now on, you can access the remote MySQL database locally through mysql -h host -r -p After the address binding is released, you need to restart the MySQL service to take effect Thank you for reading, I hope it can help you, thank you for your support of this site! You may also be interested in:
|
<<: Detailed explanation of achieving high availability of eureka through docker and docker-compose
>>: JavaScript code to implement a simple calculator
Prepare the database (MySQL). If you already have...
Table of contents variable Data Types Extension P...
Only show the top border <table frame=above>...
Table of contents Preface: 1. Concept 2. The bene...
Table of contents origin Virtual Memory Paging an...
Background of the accident: A few days ago, due t...
I always feel that translate and transition are v...
Preface: In the previous article, we mainly intro...
Table of contents 1. List interface and other mod...
Preface MySQL database lock is an important means...
Copy code The code is as follows: <span style=...
Table of contents # Post-data preparation # SQL q...
The official source code of monaco-editor-vue is ...
Table of contents event Page Loading Event Delega...
Table of contents 1. Mysql data structure 2. The ...