2

Environment: I have a database on CentOS The folder where it is saved is shared using SAMBA Windows have access to the files at \\192.168.1.101\mysql\food\ MySQL-server is running on both systems

Problem: I need to access the database on windows using mysql from CMD

Extra info: I open mysql on CMD by running: C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -h localhost -u root -p mysql>

I can not display the table on \\192.168.1.101\mysql\food\ because is not the default folder for mysql

Question: how can i change the default folder on mysql-windows to open my database? do I need something else to display the database? like add a user to mysql-server on centos and grant access

8
  • What exactly do you mean with "open this database"? You usually done "open" a MySQL database (or any server based RDBMS). You connect to a running server and run queries against it. Commented Jul 29, 2013 at 21:31
  • i have my database in centos (/var/lib/mysql/food/) and for the moment i'll be happy to do a simple "select * from nuts;" (nuts is a table in food database) from windows and see the info in CMD Commented Jul 29, 2013 at 22:05
  • So what's wrong with running the mysql command line client? The location of the actual data files is completely irrelevant for this question. Commented Jul 29, 2013 at 22:10
  • in windows i can see the database at (\\192.168.1.101\mysql\food) can i change the default directory on mysql/windos to open the databases stored in that location? and how? Commented Jul 29, 2013 at 22:24
  • Again: you can not just "open" the files of the database. You have to use a SQL client to access it (and that requires a running server to which you can connect). Commented Jul 30, 2013 at 6:07

1 Answer 1

2

you can connect to a different host by running mysql -h 123.45.67.89. Please note that there are a few security implications:

1.You will have to grant yourself access. You will need to run something like GRANT ALL on db_name.table TO user@your_ip IDENTIFIED BY 'password'.db_name, table and your_ip can be * but beware of opening your server to hackers.

2.ou will have to open your server's firewall if you are not on the same LAN. Again, ymmv and you should be aware not to open the door to exploits.

3.You may want to use SSL( http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option%5Fmysql%5Fssl ) and use secure-auth( http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option%5Fmysql%5Fsecure-auth ) in order to protect your traffic and credentials.

Hope that helps.Thanks to you

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, I grant access but from Windows/CMD what i have to type in to open the database, sorry I only have 4 hours of mysql experience

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.