Install MySQL under Ubuntu and connect to the external network

Source: Internet
Author: User

Pure Beginner Tutorial.


1. Install MySQL



During installation, you will be prompted to set a password for the database root account, enter both sides of the password

2. Enter

Mysql  


3, Reset MySQL user root password

GRANT all privileges on * * to [e-mail protected] identified by "123456";


4. Create a new Database Proxy

Create database proxy;


5, create user test to the proxy library has all the operation rights

Grant all privileges the proxy.* to [e-mail protected] identified by "testpwd";


6, Allow test users to log on from any machine MySQL



7, exit MySQL

Exit


8, after the MySQL installation is complete, the default listener address is 127.0.0.1, the port is 3306. You can see the address it listens to and the port by using the following command:

Netstat-ntulp



9, if the monitoring is 127.0.0.1, then from the external network is not connected to the database. At this point you can modify the listening address to 0.0.0.0:

sudo vim/etc/mysql/my.cnf


find bind-address=127.0.0.1 This line, change 127.0.0.1 to 0.0.0.0, save exit

10. Restart MySQL to make the configuration effective

Service MySQL Restart


You should now be able to remotely connect to the MySQL database remotely with Mysql_front or phpMyAdmin. You can only log in remotely with the test account you just authorized. The root account is forbidden by default to telnet to the database. There are two ways to allow the root account to telnet to the database:

(1). Change the table method.

It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"

<pre name= "code" class= "SQL" >mysql-u root-pmysql>use mysql;mysql>update user Set host = '% ' where user = ' ro OT '; mysql>select host, user from user;

(2). authorization law.

For example, if you want to myuser use MyPassword to connect to a MySQL server from any host:

GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' with GRANT OPTION;

if you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.3 and use MyPassword as the password

GRANT all privileges on * * to ' myuser ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION;

If security is a concern, you also want to disable the root account from logging on to the MySQL database:

Delete from user where user = ' root ' and host = '% '; Select host, user from User;flush privileges;



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.