The situation is that I have a MySQL database instance somewhere out on the network. And I’m trying to connect to it.
Logging in from the DB host
Plan:
- Open a terminal window on the DB host, 192.168.1.130
- Attempt to connect as the root db user
[root@zyxx01 ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
That didn’t work. This does, though:
[root@zyxx01 ~]# mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 171310
Server version: 5.5.32-log MySQL Community Server (GPL)
mysql>
So, don’t forget the -p option on the command-line. I guess that it tries first to connect without a password, which is a possible configuration for MySQL. And fails because it isn’t allowed in this instance.
Logging in from remote machine
My first attempt here didn’t work either, because “mysql” actually runs a batch file which expands into:
D:\>c:\progra~1\mysql\mysqls~1.5\bin\mysql.exe --defaults-file=c:\ProgramData\MySQL\mysqls~1.5\my.ini -uroot -p
Enter password: ********
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Invoking the .exe directly avoids that interesting “defaults-file” thing:
D:\>c:\progra~1\mysql\mysqls~1.5\bin\mysql.exe -h 192.168.1.130 -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 204151
Server version: 5.5.32-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Cool, we’re in. So now, let’s create a user:
mysql> create user 'abacab'@'%' identified by '****';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'abacab'@'%' ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
Testing the user:
D:\>c:\progra~1\mysql\mysqls~1.5\bin\mysql.exe -h 192.168.1.130 -u abacab -p
Enter password: ***********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 206648
Server version: 5.5.32-log MySQL Community Server (GPL)
...
mysql>
Success.
Recent Comments