Remote Access to MySQL Databases in Linux

Source: Internet
Author: User
Remote access to the mysql database: 1. First, make sure that the firewall blocks the mysql database port (3306 by default ). To disable the firewall in Linux, run the following command: # servic

Remote access to the mysql database: 1. First, make sure that the firewall blocks the mysql database port (3306 by default ). To disable the firewall in Linux, run the following command: # servic

Remote access to the mysql database:
1. First, make sure that the firewall blocks the mysql database port (default: 3306 ).
In Linux, you can use the following command to disable the Firewall:
# Service iptables stop
For more information about how to set the firewall, see log: iptables firewall settings in RadHat Linux.

2. log on to the mysql database:
A) log on with the root account in Linux
B) In Windows, click the Start menu --> Run --> enter "cmd" to go to the console --> enter the bin directory of MySQL: (cd [bin directory of MySQL])
Next, go to the MySQL database and run the following command:
# Mysql-uroot-pwtb1987
Note:
-U is followed by the database user name;
-P is followed by the password of this user;
-H is followed by the host address. The default address is localhost. The default address is used here.

3. Create a user for mysql:
① Create a java User for mysql and set the password to 123456 on IP address 192.168.127.142:

Mysql> create user 'java' @ '192. 168.127.142 'identified BY '123 ';

② If you want a java user to access the database regardless of the IP address, you only need to change the IP address to %:

Mysql> create user 'java' @ '%' identified by '20140901 ';

4. Set permissions for java users:
① For java users, if the IP address is 192.168.127.142, the SELECT and INSERT permissions can be performed on all tables in the shopping database:

Mysql> grant select, insert on 'shopping'. * TO 'java' @ '192. 168.127.142 ';

★Note: The punctuation marks on both sides of shopping are not single quotes. [Linux community]

② For java users, all operations can be performed on all tables in all databases under all IP addresses:

Mysql> grant all option on *. * TO 'java' @ '% ';

③ Task permission types (25 types ):
SELECT
INSERT
UPDATE
DELETE
CREATE
DROP
RELOAD
SHUTDOWN
PROCESS
FILE
REFERENCES
INDEX
ALTER
SHOW DATABASES
SUPER
CREATE TEMPORARY TABLES
LOCK TABLES
EXECUTE
REPLICATION SLAVE
REPLICATION CLIENT
CREATE VIEW
SHOW VIEW
CREATE ROUTINE
ALTER ROUTINE
CREATE USER

5. log on to the mysql database with a java user on a remote computer (first, ensure that the mysql database client is installed on your computer)
> Mysql-h192.168.127.142-ujava-p123456

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.