How to remotely connect to the MySQL database in Linux, linuxmysql

Source: Internet
Author: User

How to remotely connect to the MySQL database in Linux, linuxmysql

Preface

I recently encountered this requirement in my work. It is estimated that the remote connection was completed after more than an hour. A local computer and an ECS are all linux systems. Next let's take a look at the detailed introduction:

Procedure

1. enable remote access on the server

First, enter the mysql database, and then enter the following two commands:

grant all privileges on *.* to 'root'@'%' identified by 'password';flush privileges;

The first is the database, which can be changed to the name of the database that is allowed to access.

The second is the database table name, which indicates that any table can be accessed.

Root indicates the user name used for remote logon. You can customize the user name.

% Indicates that any ip address is allowed to log on. If you want to specify a specific IP address, you can replace %.

Password indicates the password used for remote logon. It can be customized.

Flush privileges; this allows the permission to take effect immediately

2. Modify the my. cnf configuration file.

This is the mysql configuration file. If you cannot find any location in the Untitled article, enterfind /* -name my.cnf Find

Use vim to edit the file and findbind-address    = 127.0.0.1In the preceding example, add a # sign to comment out and save and exit.

3. Restart the service

service mysql restart

4. Local remote connection

Enter at the terminal:

Mysql-h Server IP address-P 3306-u root-p

Enter the password.

Root is the username set at, and the password is also set

Some details

I found a lot of articles on the internet, saying that I had to enable port 3306 to connect, but I still couldn't connect to it. Later I found some articles, saying I had to change my. cnf, that is, point 2nd above, changed and then restarted the server.

I have just interviewed another server, but I have not configured any ports. The above three steps will soon be connected.

So the second point is very important. Basically, everyone configures the file when installing mysql, because the character set needs to be configured. So there must be that file. Use the find command to find it.

Summary

The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.