0

I can connect to the localhost and phpmyadmin using another computer but I was wondering if I can do something like 'mysql -u root -p' in cmd using another computer to access the database from another computer. I'm using wamp server 2.5

Jhii
  • 117
  • 3
  • 14

2 Answers2

0

Yes, you can access. You have to comment bind-address = 127.0.0.1 in my.conf file. Then restart MySQL. login using mysql -h<your-system-ip> -uroot -p

kaushik karan
  • 351
  • 2
  • 7
  • Sorry, I'm a newbie. Do I have to install wamp on the other PC? 'mysql' isn't recognized as a command in cmd. – Jhii Dec 08 '15 at 11:55
  • No need of installing wamp on another PC. You can access mysql directly from cmd prompt. To configure it, please check [this](http://stackoverflow.com/questions/5920136/mysql-is-not-recognised-as-an-internal-or-external-command-operable-program-or-b) – kaushik karan Feb 28 '16 at 17:05
0

Yes it is.

But you have to do it using a MySQL user account that is allowed to connect from another ip/domain.

A MySQL user account is made up of 2 parts, if you have seen any errors while connecting you may have seen someting like this 'root'@'localhost', they are the 2 parts.

The first part 'root' is the userid and the second part 'localhost' is the ip/domain the 'root' is connecting from. You have to create an account (best not to let root be used from anywhere!!!!!) that is allowed to connect from your other ip address, or you can use % to indicate from anywhere

Following shamlessly ripped of from that MySQL Manual

Its a good place to start

shell> mysql --user=root mysql

If you have assigned a password to the root account, you must also supply a --password or -p option.

After connecting to the server as root, you can add new accounts. The following example uses CREATE USER and GRANT statements to set up four accounts:

Setup shadow allowed access from localhost only

mysql> CREATE USER 'shadow'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     WITH GRANT OPTION;

Setup shadow allowed access from a specific ip address only

mysql> CREATE USER 'shadow'@'192.168.1.100' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     WITH GRANT OPTION;

Setup shadow allowed access from anywhere

mysql> CREATE USER 'shadow'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     WITH GRANT OPTION;

The accounts created by those statements have the following properties:

Two accounts have a user name of monty and a password of some_pass. Both are superuser accounts with full privileges to do anything. The 'shadow'@'localhost' account can be used only when connecting from the local host. The 'shadow'@'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.

The 'shadow'@'localhost' account is necessary if there is an anonymous-user account for localhost. Without the 'shadow'@'localhost' account, that anonymous-user account takes precedence when monty connects from the local host and monty is treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'shadow'@'%' account and thus comes earlier in the user table sort order. (user table sorting is discussed in Section 6.2.4, “Access Control, Stage 1: Connection Verification”.)

You may want to consider not GRANTing super user access to accounts that can connect from a machine other that the PC running MYSQL for obvious reasons.

Community
  • 1
  • 1
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149