Ubuntu16.04 server: Configure MySQL and enable remote connection. ubuntu16.04mysql

Source: Internet
Author: User

Ubuntu16.04 server: Configure MySQL and enable remote connection. ubuntu16.04mysql

Background

I recently studied nodejs and thought that I had an ECS instance, but I didn't need it for a long time. I was so worried that I had to reinstall a Ubuntu system on the cloud host, therefore, configuring MySQL becomes a step in the configuration service (node does not need to use MySQL, but it is mainly idle to reconfigure -. -). However, many problems are encountered during the configuration process. Therefore, you can leave an article for future use after solving a series of problems.

Procedure

1. Install MySQL

The blogger uses Ubuntu Server, XShell tool, and desktop version. Therefore, there is no graphic interface on the top of the page. Just use the mysql provided by the software source.

The command is as follows:

sudo apt-get install mysql-server 

After running this command, if it is not root, you will be asked to enter the root password. After the password is entered correctly, the system will automatically download MySQL for you, for example:

After completing the preceding steps, a "graphic interface :)" will be displayed to create the MySQL root Password,

After entering the information, press enter to confirm the password,

2. Authorize the user and allow remote login

If the two passwords are entered correctly, the system will help you download MySQL. However, by default, MySQL only has one root account, so create an account with the same permissions as root first, and authorize remote login permission, then we first log on to MySQL:

mysql -u root -p 

The system will ask you to enter the password. After the password is entered correctly, go to MySQL:

First, we authorize an account named Ubuntu (what is set by you) and authorize it to remotely connect. The command is as follows:

Copy codeThe Code is as follows:
Grant all privileges on *. * TO 'ubuntu '@' % 'identified by '000000' with grant option;

After running, enter the following information to update the database:

FLUSH PRIVILEGES; 

The effect is as follows:

Run quit to exit mysql.

Because MySQL is used locally by the default detachment and remote connection is not enabled, You need to modify it in the configuration file. Of course, the new MySQL version does not know why the configuration file is different from the previous one: /etc/mysql/my. cnf, but now let's see what it looks like:

Run:

sudo vi /etc/mysql/my.cnf 

The results showed that the content in my. cnf was like this. The blogger guessed that the MySQL structure was optimized.

The original configuration file is changed to the directory structure, so you can find the configuration file in the two directories mentioned above. Soon you can find the original configuration file:/etc/mysql. conf. d/mysqld. cnf

Edit it as Administrator:

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf 

Add '#' to comment out "bind-address = 127.0.0.1", for example:

 

Note: wq save and restart the MySQL service:

service mysql restart 

After verifying your Ubuntu password, the service is restarted successfully!

3. test and verification

I will try Navicat for MySQL in Windows. The configuration information is as follows (Anti-hacking: D ):

 

Let's see the results:

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.