0

I just installed mysql for the first time and created a databse with create database foo; I think I have found where mysql stores the databases (/var/lib/mysql). When I try to cd to the foo directory I get permission denied. When I try with sudo nothing happens.

output of ls -l

-rw-rw----. 1 mysql mysql    16384 Feb 21 17:44 aria_log.00000001
-rw-rw----. 1 mysql mysql       52 Feb 21 17:44 aria_log_control
drwx------. 2 mysql mysql     4096 Mar  1 22:08 foo
-rw-rw----. 1 mysql mysql 18874368 Feb 21 17:44 ibdata1
-rw-rw----. 1 mysql mysql  5242880 Mar  1 16:05 ib_logfile0
-rw-rw----. 1 mysql mysql  5242880 Feb 21 17:34 ib_logfile1
drwx------. 2 mysql mysql     4096 Feb 21 17:34 mysql
srwxrwxrwx. 1 mysql mysql        0 Mar  1 16:05 mysql.sock
drwx------. 2 mysql mysql     4096 Feb 21 17:34 performance_schema

I know your meant to view the databases and stuff through that application on the command line but I am interested as to why I can't view the foo directory when i am root.

2 Answers 2

2

You can't view the foo directory because of the permissions:

owner - mysql - read, write, execute
group - mysql - no access
other - no access
Sign up to request clarification or add additional context in comments.

2 Comments

I thought root could access everything. If not could I chown the directory and then access it?
@user3247608 "I thought root could access everything" I also thought so. But the permissions seem to be the most probable explanation. Please, try to chmod o+rx. Because if you chown to root, mysql wouldn't be able to read the databases.
0

First connect to mysql from command prompt using

[root@host]# mysql -u root -p
Enter password:******

Now select the database using

mysql> USE DB_Name

You can use belo command to have the list of databases

mysql> SHOW DATABASES;

To get the directory details you can use

mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name = "dir_name"

Comments

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.