MySQL Database remote connection

Source: Internet
Author: User
Tags safe mode

1 If you cannot connect to the localhost database (initialize the installation, forget the password).

Stop the MySQL database.

1 sudo/usr/local/mysql/support-files/mysql.server stop2// when stop failed see below how to use Mac The activity indicator stops the service. 

Enter safe Mode. Said to be safe mode, in fact is super dangerous mode! If you are modifying locally, that's fine; if it's on the server, you have to make sure that no one is logged in to the system at this time. Because once in safe mode, anyone can log in to MySQL using any password and can perform whatever action they want to do.

1 // path to MySQL Safe mode under Linux and OSX systems/usr/local/mysql/bin/mysqld_safe 2 Sudo/usr/local/mysql/bin/mysqld_safe--skip-grant-tables

Open a new terminal.

1 mysql-u root-p2//  If this is the first time you will probably not be able to use MySQL directly and access it through an absolute path. i.e. 3 /usr/local/mysql/bin/mysql-u root-p

To modify the root user password

// Switch Database // view the fields of the user table UPDATE mysql.user SET Authentication_string=password ('123456'where user='  root'// Change the root user password to 123456

After success, refresh causes the configuration to take effect

1 flush privileges;

And finally start MySQL.

1 sudo/usr/local/mysql/support-files/mysql.server start

2 is the MySQL database can be opened remotely remote access to two ways (change the table method) and (authorization method).

Http://www.jb51.net/article/85218.htm

Change Table Method:

Mysql-u root-p//log in as root user MySQLMysql>use MySQL;//Switch to mysq L databaseMysql>update UserSetHost ='%' whereuser ='Root';//Allow IP address accessMysql>SelectHost, user fromUser//To see if the update was successfulMysql>flush privileges;//Refreshing the databaseMysql>exit//Exit

Authorization law: (omitted)

3 Telnet.

Note the port number

Fool operation when using client login.

The use of terminals is:

1 mysql-u user name-p-h IP address-p port number

MySQL Database remote connection

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.