Wednesday 30 May 2012

Find Command Examples

Examples


List filenames ending in .mp3, searching in the current folder and all subfolders:
$ find . -name "*.mp3"


List filenames matching the name Alice or ALICE (case insensitive), search in the current folder (.) and all subfolders:
$ find . -iname "alice" -print0


List filenames matching the name Alice or ALICE (case insensitive), search in the current folder (.) only:
$ find . -maxdepth 1 -iname "alice" -print0


List filenames ending in .mp3, searching in the music folder and subfolders:
$ find ./music -name "*.mp3"


List files with the exact name: Sales_document.doc in ./work and subfolders:
$ find ./work -name Sales_document.doc


List all files that belong to the user Maude:
$ find . -user Maude -print0


List all the directory and sub-directory names:
$ find . -type d


List all files in those sub-directories (but not the directory names)
$ find . -type f


List all the file links:
$ find . -type l


List all files (and subdirectories) in your home directory:
$ find $HOME


Find files that are over a gigabyte in size:
$ find ~/Movies -size +1024M


Find files that are over 1 GB but less than 20 GB in size:
$ find ~/Movies -size +1024M -size -20480M -print0


Find files have been modified within the last day:
$ find ~/Movies -mtime -1


Find files have been modified within the last 30 minutes:
$ find ~/Movies -mmin -30


Find .doc files that also start with 'questionnaire' (AND)
$ find . -name '*.doc' -name questionnaire*


List all files beginning with 'memo' and owned by Maude (AND)
$ find . -name 'memo*' -user Maude


Find .doc files that do NOT start with 'Accounts' (NOT)
$ find . -name '*.doc' ! -name Accounts*


Find files named 'secrets' in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines, single or double quotes, or spaces:
$ find /tmp -name secrets -type f -print | xargs /bin/rm -f


Find files named 'secrets' in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing single or double quotes, spaces or newlines are correctly handled. The -name test comes before the -type test in order to avoid having to call stat(2) on every file.
$ find /tmp -name secrets -type f -print0 | xargs -0 /bin/rm -f


Run 'myapp' on every file in or below the current directory. Notice that the braces are enclosed in single quote marks to protect them from interpretation as shell script punctuation. The semicolon is similarly protected by the use of a backslash, though ';' could have been used in that case also.
find . -type f -exec myapp '{}' \;

Traverse the filesystem just once, listing setuid files and directories into /root/suid.txt and large files into /root/big.txt.
find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \
\( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)



Search for files in your home directory which have been modified in the last twenty-four hours. This command works this way because the time since each file was last modified is divided by 24 hours and any remainder is discarded. That means that to match -mtime 0, a file will have to have a modification in the past which is less than 24 hours ago.
find $HOME -mtime 0

Search for files which have read and write permission for their owner, and group, but which other users can read but not write to (664). Files which meet these criteria but have other permissions bits set (for example if someone can execute the file) will not be matched.
find . -perm 664


Search for files which have read and write permission for their owner and group, and which other users can read, without regard to the presence of any extra permission bits (for example the executable bit). This will match a file which has mode 0777, for example.
find . -perm -664


Search for files which are writable by somebody (their owner, or their group, or anybody else).
find . -perm /222


All three of these commands do the same thing, but the first one uses the octal representation of the file mode, and the other two use the symbolic form. These commands all search for files which are writable by either their owner or their group. The files don't have to be writable by both the owner and group to be matched; either will do.
find . -perm /220
find . -perm /u+w,g+w
find . -perm /u=w,g=w



Both these commands do the same thing; search for files which are writable by both their owner and their group.
find . -perm -220
find . -perm -g+w,u+w



These two commands both search for files that are readable for everybody (-perm -444 or -perm -a+r), have at least on write bit set (-perm /222 or -perm /a+w) but are not executable for anybody (! -perm /111 and ! -perm /a+x respectively)
find . -perm -444 -perm /222 ! -perm /111
find . -perm -a+r -perm /a+w ! -perm /a+x



Performance
If you need to run an action against a large quantity of files, an alternative and often much faster method is to execute the command by simply piping find into xargs rather than specifying a find action against each file.


xargs, will bundle up the files and (almost always) run them through a single instance of the called program
find -exec, will run a separate instance of the called program for each file.
Exit Status
find exits with status 0 if all files are processed successfully, greater than 0 if errors occur. This is deliberately a very broad description, but if the return value is non-zero, you should not rely on the correctness of the results of find.


As of findutils-4.2.2, shell metacharacters ('*'. '?' or '[]' for example) used in filename patterns will match a leading '.', because IEEE POSIX interpretation 126 requires this.
Non-bugs
$ find . -name *.c -print
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
This happens because *.c has been expanded by the shell resulting in find actually receiving a command line like this:
find . -name bigram.c code.c frcode.c locate.c -print


That command is of course not going to work. Instead of doing things this way, you should enclose the pattern in quotes:
$ find . -name ´*.c´ -print

delete all directories EXCEPT a particular one

For those of you that just want the straight goods, here’s how we delete everything EXCEPT the ‘backup’ directory:
find . -maxdepth 1 ! -name 'backup' ! -name '.*' | xargs rm -rf

Q:http://www.askdavetaylor.com/how_do_i_delete_all_but_one_directory_in_linux.html




--------------------------------------

The example in the Smooth Operator boxout creates an m3u playlist listing all ogg files that start 'David Gray' (and all case-permutations)
$ find . -iname david\ gray\*ogg -type f > david_gray.m3u
This will find any files called, in one way or the other, "david gray....ogg".
This is semantically equivalent to:
$ find . -iname david\ gray\*ogg -and -type f > david_gray.m3u
It's equivalent to:
$ find . -iname "david gray*ogg" -and -type f > david_gray.m3u
What if the ogg files themselves mightn't have the artists name in them and are in some subdirectory of one called 'David Gray', how do we find them?
$ find . -ipath \*david\ gray\*ogg -type f > david_gray.m3u
The expression starts with a wildcard because its possible there's more than one subdirectory named 'david gray' that might really be nothing more than symlinks for categorisations.

Here's another example, we list the contents of the humour directory (one line per file) and do a case-insensitive search for .mp3 files with 'yoda' in the name of the file:
$ ls humour -1
Weird Al - Yoda.mp3
welcome_to_the_internet_helpdesk.mp3
werid al - livin' la vida yoda.mp3

$ find -ipath \*humour\*yoda\* -type f
./humour/Weird Al - Yoda.mp3
./humour/werid al - livin' la vida yoda.mp3


2 into 1 does go

As implied in the Smooth Operator boxout, it's possible to have one invocation of find perform more than one task.
To compile two lists, one containing the names of all .php files and the other the names of all .js files use:
$ find ~ -type f \( -name \*.php -fprint php_files , 
                    -name \*.js -fprint javascript_files \)


Pruning

Suppose you have a playlist file listing all David Gray .ogg files but there are a few albums you don't want included.
You can prevent those albums from going into the playlist by using the -prune action which works by attempting to match the names of directories against the given expression.
This example excludes the Flesh and Lost Songs albums :
$ find   \( -path  ./mp3/David_Gray/Flesh\* -o -path
"./mp3/David_Gray/Lost Songs" \* \) -prune -o -ipath \*david\ gray\*
The first thing you'll notice here is the parentheses are escaped out so BASH doesn't misinterpret them. Notice using -prune takes the form
"don't look for these, look for these other ones instead". ie:
$ find (-path <don't want this> -o -path <don't want this#2>)
\-prune -o -path <global expression for what I do want>
It might take a bit longer to invoke find to use the -prune action: decide exactly what you want to do first. I find using the -prune action saves me time I can use on other tasks.

Fussy Fozzy!

There's a host of other expressions and criteria that can be used with find.
Here is a brief rundown on the ones you'll most likely want to use:
-nouserfile is owned by someone no longer listed in /etc/passwd
-nogroupthe group the file belongs to is no longer listed in /etc/groups
-owner <username>file is owned by specified user.
We'll delve into using these, and others, later on.


Print me the way you want me, baby!


Changing the output information

If you want more than just the names of the files displayed, find's -printf action lets you have just about any type of information displayed. Looking at the man page there is a startling array of options.
These are used the most:
%pfilename, including name(s) of directory the file is in
%mpermissions of file, displayed in octal.
%fdisplays the filename, no directory names are included
%gname of the group the file belongs to.
%hdisplay name of directory file is in, filename isn't included.
%uusername of the owner of the file
As an example:
$ find . -name \*.ogg -printf %f\\n
generates a list of the filenames of all .ogg files in and under the current directory.
The 'double backslash n' is important; '\n' indicates the start of a new line. The single backslash needs to be escaped by another one so the shell doesn't take it as one of its own.



Where to output information?


find has a set of actions that tell it to write the information to any file you wish. These are the -fprint, -fprint0 and -fprintf actions.

Thus
$ find . -iname david\ gray\*ogg -type f -fprint david_gray.m3u
is more efficient than
$ find . -iname david\ gray\*ogg -type f > david_gray.m3u


Execute!

File is an excellent tool for generating reports on basic information regarding files, but what if you want more than just reports? You could just pipe the output to some other utility:
$ find ~/oggs/ -iname \*.mp3 | xargs rm
This isn't all that efficient though.
It is much better to use the -exec action:
$ find ~/oggs/ -iname \*.mp3 -exec rm {} \;
It mightn't read as well, but it does mean the files are immediately deleted once found.
'{}' is a placeholder for the name of the file that has been found and as we want BASH to ignore the semicolon and pass it verbatim to find we have to escape it.
To be cautious, the -ok action can be used instead of -exec. The -ok action means you'll be asked for confirmation before the command is executed.
There are many ways these can be used in 'real life' situations:
If you are locked out from the default Mozilla profile, this will unlock you:
$ find ~/.mozilla -name lock -exec rm {} \;
To compress .log files on an individual basis:
$ find . -name \*.log -exec bzip {} \;
Give user ken ownership of files that aren't owned by any current user:
$ find . -nouser -exec chown ken {} \;
View all .dat files that are in the current directory with vim. Don't search any subdirectories.
$ vim -R `find . -name \*.dat -maxdepth 1`
Look for directories called CVS which are at least four levels below the current directory:
$ find -mindepth 4 -type d -name CVS 


Time waits for no-one

You might want to search for recently created files, or grep through the last 3 days worth of log files.
Find comes into its own here: it can limit the scope of the files found according to timestamps.
Now, suppose you want to see what hidden files in your home directory changed in the last 5 days:
$ find ~ -mtime -5 -name \.\*
If you know something has changed much more recently than that, say in the last 14 minutes, and want to know what it was there's the mmin argument:
$ find ~ -mmin 14 -name \.\*
Be aware that doing a 'ls' will affect the access time-stamps of the files shown by that action. If you do an ls to see what's in a directory and try the above to see what files were accessed in the last 14 minutes all files will be listed by find.
To locate files that have been modified since some arbitrary date use this little trick:
$ touch -d "13 may 2001 17:54:19" date_marker
$ find . -newer date_marker 
To find files created before that date, use the cnewer and negation conditions:
$ find . \! -cnewer date_marker
To find a file which was modified yesterday, but less than 24 hours ago:
$ find . -daystart -atime 1 -maxdepth
The -daystart argument means the day starts at the actual beginning of the day, not 24 hours ago.
This argument has meaning for the -amin, -atime, -cmin, ctime, -mmin and -mtime options.



Empty files

You can find empty files with $ find . -size 0c 
Using the -empty argument is more efficient.
To delete empty files in the current directory:
$ find . -empty -maxdepth 1 -exec rm {} \;


Users & Groupies


Users

To locate files belonging to a certain user:
# find /etc -type f \!  -user root -exec ls -l {} \;
-rw------- 1 lp sys 19731 2002-08-23 15:04 /etc/cups/cupsd.conf
-rw------- 1 lp sys    97 2002-07-26 23:38 /etc/cups/printers.conf
A subset of that same information, without having the cost of an exec:
root@ttyp0[etc]# find /etc -type f \!  -user root \
                 -printf "%h/%f %u\\n"
/etc/cups/cupsd.conf lp
/etc/cups/printers.conf lp
If you know the uid and not the username then use the -uid argument:
$ find /usr/local/htdocs/www.linux.ie/ -uid 401
-nouser means there is no user in the /etc/passwd file for the files in question.


Groupies

find can locate files that belong to a specific group - or not, depending on how you use it.
This is especially suited to tracking down files that should belong to the www group but don't:
$ find /www/ilug/htdocs/  -type f \! -group  www
The -nogroup argument means there is no group in the /etc/group file for the files in question.
This may arise if a group is removed from the /etc/group file sometime after it's been used.
To search for files by the numerical group ID use the -gid argument:
$ find -gid 100


Permissions

If you've ever had one or more shell scripts not work because their execute bits weren't set and want to sort things out for once and for all, then you should like this little example:
knoppix@ttyp1[bin]$ ls -l ~/bin/
total 8
-rwxr-xr-x    1 knoppix  knoppix 21 2004-01-20 21:42 wl
-rw-r--r--    1 knoppix  knoppix 21 2004-01-20 21:47 ww

knoppix@ttyp1[bin]$ find ~/bin/ -maxdepth 1 -perm 644 -type f \
                    -not -name .\* 
/home/knoppix/bin/ww
Find locates the file that isn't set to execute, as we can see from the output of ls.


Types of files

The '-type' argument obviously specifies what type of file find is to go looking for (remember in Linux absolutely everything is represented as some type of file).
So far I've been using '-type f' which means search for normal files.
If we want to locate directories with '_of_' in their name we'd use:
$ find . -type d -name '*_of_*'
The list generated by this won't include symbolic links to directories.
To get a list including directories and symbolic links:
$ find . \( -type d -or -type l \) -name '*_of_*'
For a complete list of types check the man page.


Limiting by filesytem

As an experiment, get a MS formatted floppy disk and mount it as root:
$ su - 
# mount /floppy
# mount
/dev/sda2 on / type ext2 (rw,errors=remount-ro)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/fd0 on /floppy type msdos (rw,noexec,nosuid,nodev)
Now try
$ find / -fstype msdos -maxdepth 1 
You should see only /floppy listed.
To get the reverse of this, ie a listing of directories that are not on msdos file-systems, use

$ find / -maxdepth 1 \( -fstype msdos \) -prune -or -print
This is a start on limiting the files found by system type.

Tuesday 29 May 2012

PhpMyadmin FAQ'S

Server

1.1 I'm running PHP 4+ and my server is crashing each time a specific action is required or phpMyAdmin sends a blank page or a page full of cryptic characters to my browser, what can I do?

There are some known PHP bugs with output buffering and compression.
Try to set the $cfg['OBGzip'] directive to FALSE in your config.inc.php file and the zlib.output_compression directive to Off in your php configuration file.
Furthermore, we know about such problems connected to the release candidates of PHP 4.2.0 (tested with PHP 4.2.0 RC1 to RC4) together with MS Internet Explorer. Please upgrade to the release version PHP 4.2.0.

1.2 My Apache server crashes when using phpMyAdmin.

You should first try the latest versions of Apache (and possibly MySQL).
See also the FAQ 1.1 entry about PHP bugs with output buffering.
If your server keeps crashing, please ask for help in the various Apache support groups.

1.3 I'm running phpMyAdmin with "cookie" authentication mode under PHP 4.2.0 or 4.2.1 loaded as an Apache 2 module but can't enter the script: I'm always displayed the login screen.

This is a known PHP bug (see this bug report) from the official PHP bug database. It means there is and won't be any phpMyAdmin fix against it because there is no way to code a fix.

1.4 Using phpMyAdmin on IIS, I'm displayed the error message: "The specified CGI application misbehaved by not returning a complete set of HTTP headers ...".

You just forgot to read the install.txt file from the php distribution. Have a look at the last message in this bug report from the official PHP bug database.

1.5 Using phpMyAdmin on IIS, I'm facing crashes and/or many error messages with the HTTP or advanced authentication mode.

This is a known problem with the PHP ISAPI filter: it's not so stable. Please use instead the cookie authentication mode.

1.6 I can't use phpMyAdmin on PWS: nothing is displayed!

This seems to be a PWS bug. Filippo Simoncini found a workaround (at this time there is no better fix): remove or comment the DOCTYPE declarations (2 lines) from the scripts libraries/header.inc.php, libraries/header_printview.inc.php, index.php, navigation.php and libraries/common.lib.php.

1.7 How can I GZip or Bzip a dump or a CSV export? It does not seem to work.

These features are based on the gzencode() and bzcompress() PHP functions to be more independent of the platform (Unix/Windows, Safe Mode or not, and so on). So, you must have PHP4 >= 4.0.4 and Zlib/Bzip2 support (--with-zlib and --with-bz2).
We faced PHP crashes when trying to download a dump with MS Internet Explorer when phpMyAdmin is run with a release candidate of PHP 4.2.0. In this case you should switch to the release version of PHP 4.2.0.

1.8 I cannot insert a text file in a table, and I get an error about safe mode being in effect.

Your uploaded file is saved by PHP in the "upload dir", as defined in php.ini by the variable upload_tmp_dir (usually the system default is /tmp).
We recommend the following setup for Apache servers running in safe mode, to enable uploads of files while being reasonably secure:
  • create a separate directory for uploads: mkdir /tmp/php
  • give ownership to the Apache server's user.group: chown apache.apache /tmp/php
  • give proper permission: chmod 600 /tmp/php
  • put upload_tmp_dir = /tmp/php in php.ini
  • restart Apache

1.9 I'm having troubles when uploading files. In general file uploads don't work on my system and uploaded files have a Content-Type: header in the first line.

It's not really phpMyAdmin related but RedHat 7.0. You have a RedHat 7.0 and you updated your PHP RPM to php-4.0.4pl1-3.i386.rpm, didn't you?
So the problem is that this package has a serious bug that was corrected ages ago in PHP (2001-01-28: see PHP's bug tracking system for more details). The problem is that the bugged package is still available though it was corrected (see RedHat's BugZilla for more details).
So please download the fixed package (4.0.4pl1-9) and the problem should go away.
And that fixes the \r\n problem with file uploads!

1.10 I'm having troubles when uploading files with phpMyAdmin running on a secure server. My browser is Internet Explorer and I'm using the Apache server.

As suggested by "Rob M" in the phpWizard forum, add this line to your httpd.conf:
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
It seems to clear up many problems between Internet Explorer and SSL.

1.11 I get an 'open_basedir restriction' while uploading a file from the query box.

Since version 2.2.4, phpMyAdmin supports servers with open_basedir restrictions. However you need to create temporary directory and configure it as $cfg['TempDir']. The uploaded files will be moved there, and after execution of your SQL commands, removed.

1.12 I have lost my MySQL root password, what can I do?

The MySQL manual explains how to reset the permissions.

1.13 I get an error 'No SQL query' when trying to execute a bookmark.

If PHP does not have read/write access to its upload_tmp_dir, it cannot access the uploaded query.

1.14 I get an error 'No SQL query' when trying to submit a query from the convenient text area.

Check the post_max_size directive from your PHP configuration file and try to increase it.

1.15 I have problems with mysql.user field names.

In previous MySQL versions, the User and Password fields were named user and password. Please modify your field names to align with current standards.

1.16 I cannot upload big dump files (memory, HTTP or timeout problems).

Starting with version 2.7.0, the import engine has been re–written and these problems should not occur. If possible, upgrade your phpMyAdmin to the latest version to take advantage of the new import features.
The first things to check (or ask your host provider to check) are the values of upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. One user also said that post_max_size and memory_limit need to be larger than upload_max_filesize.

There exist several workarounds if your upload is too big or your hosting provider is unwilling to change the settings:
  • Look at the $cfg['UploadDir'] feature. This allows one to upload a file to the server via scp, ftp, or your favorite file transfer method. PhpMyAdmin is then able to import the files from the temporary directory. More information is available in the Configuration section of this document.
  • Using a utility (such as BigDump) to split the files before uploading. We cannot support this or any third party applications, but are aware of users having success with it.
  • If you have shell (command line) access, use MySQL to import the files directly. You can do this by issuing the "source" command from within MySQL: source filename.sql.

1.17 Which MySQL versions does phpMyAdmin support?

All MySQL versions from 3.23.32 till 5.0 (except for 4.1.0 and 4.1.1) are fully supported. Please note that the older your MySQL version is, the more limitations you will have to face.
phpMyAdmin may connect to your MySQL server using php's classic MySQL extension as well as the improved MySQL extension (MySQLi) that is available in php 5.0.
Either way, the developers of both extensions recommend to use the classic extension for MySQL 4.0 and below and MySQLi for MySQL 4.1 and newer.
When compiling php, we strongly recommend that you manually link the MySQL extension of your choice to a MySQL client library of at least the same minor version since the one that is bundled with some php distributions is rather old and might cause problems (see FAQ 1.17a). If your webserver is running on a windows system, you might want to try MySQL's Connector/PHP instead of the MySQL / MySQLi extensions that are bundled with the official php Win32 builds.
MySQL 5.1 is not yet supported.
1.17a I cannot connect to the MySQL server. It always returns the error message, "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
You tried to access MySQL with an old MySQL client library. The version of your MySQL client library can be checked in your phpinfo() output. In general, it should have at least the same minor version as your server - as mentioned in FAQ 1.17.

This problem is generally caused by using MySQL version 4.1 or newer. MySQL changed the authentication hash and your PHP is trying to use the old method. The proper solution is to use the mysqli extension with the proper client library to match your MySQL installation. Your chosen extension is specified in $cfg['Servers'][$i]['extension']. More information (and several workarounds) are located in the MySQL Documentation.

1.18 I'm running MySQL <= 4.0.1 having lower_case_table_names set to 1. If I create a new table with a capital letter in its name it is changed to lowercase as it should. But if I try to DROP this table MySQL is unable to find the corresponding file.

This is a bug of MySQL <= 4.0.1. Please upgrade to at least MySQL 4.0.2 or turn off your lower_case_table_names directive.

1.19 I can't run the "display relations" feature because the script seems not to know the font face I'm using!

The "FPDF" library we're using for this feature requires some special files to use font faces.
Please refers to the FPDF manual to build these files.

1.20 I receive the error "cannot load MySQL extension, please check PHP Configuration".

To connect to a MySQL server, PHP needs a set of MySQL functions called "MySQL extension". This extension may be part of the PHP distribution (compiled-in), otherwise it needs to be loaded dynamically. Its name is probably mysql.so or php_mysql.dll. phpMyAdmin tried to load the extension but failed.

Usually, the problem is solved by installing a software package called "PHP-MySQL" or something similar.

1.21 I am running the CGI version of PHP under Unix, and I cannot log in using cookie auth.

In php.ini, set mysql.max_links higher than 1.

1.22 I don't see the "Location of text file" field, so I cannot upload.

This is most likely because in php.ini, your file_uploads parameter is not set to "on".

1.23 I'm running MySQL on a Win32 machine. Each time I create a new table the table and field names are changed to lowercase!

This happens because the MySQL directive lower_case_table_names defaults to 1 (ON) in the Win32 version of MySQL. You can change this behavior by simply changing the directive to 0 (OFF):
Just edit your my.ini file that should be located in your Windows directory and add the following line to the group [mysqld]:
set-variable = lower_case_table_names=0
Next, save the file and restart the MySQL service. You can always check the value of this directive using the query
SHOW VARIABLES LIKE 'lower_case_table_names';

1.24 Some characters are being truncated in my queries, or I get characters randomly added. I am running PHP 4.2.3.

This is a PHP 4.2.3 bug.

1.25 I am running Apache with mod_gzip-1.3.26.1a on Windows XP, and I get problems, such as undefined variables when I run a SQL query.

A tip from Jose Fandos: put a comment on the following two lines in httpd.conf, like this:
# mod_gzip_item_include file \.php$
# mod_gzip_item_include mime "application/x-httpd-php.*"
as this version of mod_gzip on Apache (Windows) has problems handling PHP scripts. Of course you have to restart Apache.

1.26 I just installed phpMyAdmin in my document root of IIS but I get the error "No input file specified" when trying to run phpMyAdmin.

This is a permission problem. Right-click on the phpmyadmin folder and choose properties. Under the tab Security, click on "Add" and select the user "IUSR_machine" from the list. Now set his permissions and it should work.

1.27 I get empty page when I want to view huge page (eg. db_structure.php with plenty of tables).

This is a PHP bug that occur when GZIP output buffering is enabled. If you turn off it (by $cfg['OBGzip'] = false in config.inc.php), it should work. This bug will be fixed in PHP 5.0.0.

1.28 My MySQL server sometimes refuses queries and returns the message 'Errorcode: 13'. What does this mean?

This can happen due to a MySQL bug when having database / table names with upper case characters although lower_case_table_names is set to 1. To fix this, turn off this directive, convert all database and table names to lower case and turn it on again. Alternatively, there's a bug-fix available starting with MySQL 3.23.56 / 4.0.11-gamma.

1.29 When I create a table or modify a field, I get an error and the fields are duplicated.

It is possible to configure Apache in such a way that PHP has problems interpreting .php files.
The problems occur when two different (and conflicting) set of directives are used:
SetOutputFilter PHP
SetInputFilter PHP
and
AddType application/x-httpd-php .php
In the case we saw, one set of directives was in /etc/httpd/conf/httpd.conf, while the other set was in /etc/httpd/conf/addon-modules/php.conf.
The recommended way is with AddType, so just comment out the first set of lines and restart Apache:
#SetOutputFilter PHP
#SetInputFilter PHP

1.30 I get the error "navigation.php: Missing hash".

This problem is known to happen when the server is running Turck MMCache but upgrading MMCache to version 2.3.21 solves the problem.

1.31 Does phpMyAdmin support php5?

Yes.
However, phpMyAdmin needs to be backwards compatible to php4. This is why phpMyAdmin disables the E_STRICT error_level in error_reporting settings.

1.32 Can I use HTTP authentication with IIS?

Yes. This procedure was tested with phpMyAdmin 2.6.1, PHP 4.3.9 in ISAPI mode under IIS 5.1.
  1. In your php.ini file, set cgi.rfc2616_headers = 0
  2. In Web Site Properties -> File/Directory Security -> Anonymous Access dialog box, check the Anonymous access checkbox and uncheck any other checkboxes (i.e. uncheck Basic authentication, Integrated Windows authentication, and Digest if it's enabled.) Click OK.
  3. In Custom Errors, select the range of 401;1 through 401;5 and click the Set to Default button.

1.33 Is there a problem with the mysqli extension when running PHP 5.0.4 on 64-bit systems?

Yes. This problem affects phpMyAdmin ("Call to undefined function pma_reloadnavigation"), so upgrade your PHP to the next version.

1.34 Can I access directly to database or table pages?

Yes. Out of the box, you can use URLs like http://server/phpMyAdmin/index.php?server=X&db=database&table=table&target=script. For server you use the server number which refers to the order of the server paragraph in config.inc.php. Table and script parts are optional. If you want http://server/phpMyAdmin/database[/table][/script] URLs, you need to do some configuration. Following lines apply only for Apache web server. First make sure, that you have enabled some features within global configuration. You need Options FollowSymLinks and AllowOverride FileInfo enabled for directory where phpMyAdmin is installed and you need mod_rewrite to be enabled. Then you just need to create following .htaccess file in root folder of phpMyAdmin installation (don't forget to change directory name inside of it):
RewriteEngine On
RewriteBase /path_to_phpMyAdmin
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([a-z_]+\.php)$ index.php?db=$1&table=$2&target=$3 [R]
RewriteRule ^([a-zA-Z0-9_]+)/([a-z_]+\.php)$ index.php?db=$1&target=$2 [R]
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?db=$1&table=$2 [R]
RewriteRule ^([a-zA-Z0-9_]+)$ index.php?db=$1 [R]

1.35 Can I use HTTP authentication with Apache CGI?

Yes. However you need to pass authentication variable to CGI using following rewrite rule:
RewriteEngine On
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]

1.36 I get an error "500 Internal Server Error".

There can be many explanations to this and a look at your server's error log file might give a clue.

1.37 I run phpMyAdmin on cluster of different machines and password encryption in cookie auth doesn't work.

If your cluster consist of different architectures, PHP code used for encryption/decryption won't work correct. This is caused by use of pack/unpack functions in code. Only solution is to use mcrypt extension which works fine in this case.

1.38 Can I use phpMyAdmin on a server on which Suhosin is enabled?

Yes but the default configuration values of Suhosin are known to cause problems with some operations, for example editing a table with many columns and no primary key. Tuning information is available at http://www.hardened-php.net/hphp/troubleshooting.html, although the parameter names have changed (suhosin instead of hphp). See also the SuhosinDisableWarning directive.

Configuration

2.1 The error message "Warning: Cannot add header information - headers already sent by ..." is displayed, what's the problem?

Edit your config.inc.php file and ensure there is nothing (I.E. no blank lines, no spaces, no characters...) neither before the <?php tag at the beginning, neither after the ?> tag at the end. We also got a report from a user under IIS, that used a zipped distribution kit: the file libraries/Config.class.php contained an end-of-line character (hex 0A) at the end; removing this character cleared his errors.

2.2 phpMyAdmin can't connect to MySQL. What's wrong?

Either there is an error with your PHP setup or your username/password is wrong. Try to make a small script which uses mysql_connect and see if it works. If it doesn't, it may be you haven't even compiled MySQL support into PHP.

2.3 The error message "Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) ..." is displayed. What can I do?

For RedHat users, Harald Legner suggests this on the mailing list:
On my RedHat-Box the socket of MySQL is /var/lib/mysql/mysql.sock. In your php.ini you will find a line
mysql.default_socket = /tmp/mysql.sock
change it to
mysql.default_socket = /var/lib/mysql/mysql.sock
Then restart apache and it will work.
Here is a fix suggested by Brad Ummer:
  • First, you need to determine what socket is being used by MySQL.
    To do this, telnet to your server and go to the MySQL bin directory. In this directory there should be a file named mysqladmin. Type ./mysqladmin variables, and this should give you a bunch of info about your MySQL server, including the socket (/tmp/mysql.sock, for example).
  • Then, you need to tell PHP to use this socket.
    To do this in phpMyAdmin, you need to complete the socket information in the config.inc.php.
    For example: $cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';

    Please also make sure that the permissions of this file allow to be readable by your webserver (i.e. '0755').
Have also a look at the corresponding section of the MySQL documentation.

2.4 Nothing is displayed by my browser when I try to run phpMyAdmin, what can I do?

Try to set the $cfg['OBGZip'] directive to FALSE in the phpMyAdmin configuration file. It helps sometime.
Also have a look at your PHP version number: if it contains "4.0b..." it means you're running a beta version of PHP. That's not a so good idea, please upgrade to a plain revision.

2.5 Each time I want to insert or change a record or drop a database or a table, an error 404 (page not found) is displayed or, with HTTP or cookie authentication, I'm asked to log in again. What's wrong?

Check the value you set for the $cfg['PmaAbsoluteUri'] directive in the phpMyAdmin configuration file.

2.6 I get an "Access denied for user: 'root@localhost' (Using password: YES)"-error when trying to access a MySQL-Server on a host which is port-forwarded for my localhost.

When you are using a port on your localhost, which you redirect via port-forwarding to another host, MySQL is not resolving the localhost as expected.
Erik Wasser explains: The solution is: if your host is "localhost" MySQL (the commandline tool 'mysql' as well) always tries to use the socket connection for speeding up things. And that doesn't work in this configuration with port forwarding.
If you enter "127.0.0.1" as hostname, everything is right and MySQL uses the TCP connection.

2.7 Using and creating themes

Themes are configured with $cfg['ThemePath'], $cfg['ThemeManager'] and $cfg['ThemeDefault'].

Under $cfg['ThemePath'], you should not delete the directory "original" or its underlying structure, because this is the system theme used by phpMyAdmin. "original" contains all images and styles, for backwards compatibility and for all themes that would not include images or css-files.

If $cfg['ThemeManager'] is enabled, you can select your favorite theme on the main page. Your selected theme will be stored in a cookie.

To create a theme:
  • make a new subdirectory (for example "your_theme_name") under $cfg['ThemePath'] (by default themes)
  • copy the files and directories from "original" to "your_theme_name"
  • edit the css-files in "your_theme_name/css"
  • put your new images in "your_theme_name/img"
  • edit layout.inc.php in "your_theme_name"
  • edit info.inc.php in "your_theme_name" to contain your chosen theme name, that will be visible in user interface
  • make a new screenshot of your theme and save it under "your_theme_name/screen.png"
In theme directory there is file info.inc.php which contains theme verbose name, theme generation and theme version. These versions and generations are enumerated from 1 and do not have any direct dependence on phpMyAdmin version. Themes within same generation should be backwards compatible - theme with version 2 should work in phpMyAdmin requiring version 1. Themes with different generation are incompatible.
If you do not want to use your own symbols and buttons, remove the directory "img" in "your_theme_name". phpMyAdmin will use the default icons and buttons (from the system-theme "original").

2.8 I get "Missing parameters" errors, what can I do?

Here are a few points to check:
  • In config.inc.php, try to leave the $cfg['PmaAbsoluteUri'] directive empty. See also FAQ 4.7.
  • Maybe you have a broken PHP installation or you need to upgrade your Zend Optimizer. See http://bugs.php.net/bug.php?id=31134.
  • If you are using Hardened PHP with the ini directive varfilter.max_request_variables set to the default (200) or another low value, you could get this error if your table has a high number of columns. Adjust this setting accordingly. (Thanks to Klaus Dorninger for the hint).
  • In the php.ini directive arg_separator.input, a value of ";" will cause this error. Replace it with "&;".
  • If you are using Hardened-PHP, you might want to increase request limits.
  • The directory specified in the php.ini directive session.save_path does not exist or is read-only.

Known limitations

3.1 When using HTTP authentication, an user who logged out can not log in again in with the same nick.

This is related to the authentication mechanism (protocol) used by phpMyAdmin. To bypass this problem: just close all the opened browser windows and then go back to phpMyAdmin. You should be able to log in again.

3.2 When dumping a large table in compressed mode, I get a memory limit error or a time limit error.

Compressed dumps are built in memory and because of this are limited to php's memory limit. For GZip/BZip2 exports this can be overcome since 2.5.4 using $cfg['CompressOnFly'] (enabled by default). Zip exports can not be handled this way, so if you need Zip files for larger dump, you have to use another way.

3.3 With InnoDB tables, I lose foreign key relationships when I rename or alter a table.

This seems to be a InnoDB bug (fixed in MySQL 3.23.50?).

3.4 I am unable to import dumps I created with the mysqldump tool bundled with the MySQL server distribution.

The problem is that older versions of mysqldump created invalid comments like this:
-- MySQL dump 8.22
--
-- Host: localhost Database: database
---------------------------------------------------------
-- Server version 3.23.54
The invalid part of the code is the horizontal line made of dashes that appears once in every dump created with mysqldump. If you want to run your dump you have to turn it into valid MySQL. This means, you have to add a whitespace after the first two dashes of the line or add a # before it:
-- -------------------------------------------------------
or
#---------------------------------------------------------

3.5 When using nested folders there are some multiple hierarchies displayed in a wrong manner?! ($cfg['LeftFrameTableSeparator'])

Please note that you should not use the separating string multiple times without any characters between them, or at the beginning/end of your table name. If you have to, think about using another TableSeparator or disabling that feature

3.6 What is currently not supported in phpMyAdmin about InnoDB?

In Relation view, being able to choose a table in another database, or having more than one index field in the foreign key.

In Query-by-example (Query), automatic generation of the query LEFT JOIN from the foreign table.


3.7 I have table with many (100+) fields and when I try to browse table I get series of errors like "Warning: unable to parse url". How can this be fixed?

Your table neither have a primary key nor an unique one, so we must use a long expression to identify this row. This causes problems to parse_url function. The workaround is to create a primary or unique key.

3.8 I cannot use (clickable) HTML-forms in fields where I put a MIME-Transformation onto!

Due to a surrounding form-container (for multi-row delete checkboxes), no nested forms can be put inside the table where phpMyAdmin displays the results. You can, however, use any form inside of a table if keep the parent form-container with the target to tbl_row_delete.php and just put your own input-elements inside. If you use a custom submit input field, the form will submit itself to the displaying page again, where you can validate the $HTTP_POST_VARS in a transformation. For a tutorial on how to effectively use transformations, see our Link section on the official phpMyAdmin-homepage.

3.9 I get error messages when using "--sql_mode=ANSI" for the MySQL server

When MySQL is running in ANSI-compatibility mode, there are some major differences in how SQL is structured (see http://dev.mysql.com/doc/mysql/en/ANSI_mode.html). Most important of all, the quote-character (") is interpreted as an identifier quote character and not as a string quote character, which makes many internal phpMyAdmin operations into invalid SQL statements. There is no workaround to this behaviour. News to this item will be posted in Bug report #816858

3.10 Homonyms and no primary key: When the results of a SELECT display more that one column with the same value (for example SELECT lastname from employees where firstname like 'A%' and two "Smith" values are displayed), if I click Edit I cannot be sure that I am editing the intended row.

Please make sure that your table has a primary key, so that phpMyAdmin can use it for the Edit and Delete links.

3.11 The number of records for InnoDB tables is not correct.

phpMyAdmin uses a quick method to get the row count, and this method only returns an approximate count in the case of InnoDB tables. See $cfg['MaxExactCount'] for a way to modify those results, but this could have a serious impact on performance.

3.12 What are the phpMyAdmin limitations for MySQL 3?

The number of records in queries containing COUNT and GROUP BY is not correctly calculated. Also, sorting results of a query like "SELECT * from table GROUP BY" ... is problematic.

3.13 I get an error when entering USE followed by a db name containing an hyphen.

The tests I have made with current MySQL 4.1.11 API shows that the API does not accept this syntax for the USE command. Enclosing the db name with backquotes works. For further confusion, no backquotes are needed with command-line mysql.

3.14 I am not able to browse a table when I don't have the right to SELECT one of the columns.

This has been a known limitation of phpMyAdmin since the beginning and it's not likely to be solved in the future.

ISPs, multi-user installations

4.1 I'm an ISP. Can I setup one central copy of phpMyAdmin or do I need to install it for each customer.

Since version 2.0.3, you can setup a central copy of phpMyAdmin for all your users. The development of this feature was kindly sponsored by NetCologne GmbH. This requires a properly setup MySQL user management and phpMyAdmin HTTP or cookie authentication. See the install section on "Using HTTP authentication".

4.2 What's the preferred way of making phpMyAdmin secure against evil access.

This depends on your system.
If you're running a server which cannot be accessed by other people, it's sufficient to use the directory protection bundled with your webserver (with Apache you can use .htaccess files, for example).
If other people have telnet access to your server, you should use phpMyAdmin's HTTP or cookie authentication features.

Suggestions:
  • Your config.inc.php file should be chmod 660.
  • All your phpMyAdmin files should be chown -R phpmy.apache, where phpmy is a user whose password is only known to you, and apache is the group under which Apache runs.
  • You should use PHP safe mode, to protect from other users that try to include your config.inc.php in their scripts.

4.3 I get errors about not being able to include a file in /lang or in /libraries.

Check php.ini, or ask your sysadmin to check it. The include_path must contain "." somewhere in it, and open_basedir, if used, must contain "." and "./lang" to allow normal operation of phpMyAdmin.

4.4 phpMyAdmin always gives "Access denied" when using HTTP authentication.

This could happen for several reasons:

4.5 Is it possible to let users create their own databases?

Starting with 2.2.5, in the user management page, you can enter a wildcard database name for a user (for example "joe%"), and put the privileges you want. For example, adding SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER would let a user create/manage his/her database(s).

4.6 How can I use the Host-based authentication additions?

If you have existing rules from an old .htaccess file, you can take them and add a username between the 'deny'/'allow' and 'from' strings. Using the username wildcard of '%' would be a major benefit here if your installation is suited to using it. Then you can just add those updated lines into the $cfg['Servers'][$i]['AllowDeny']['rules'] array.
If you want a pre-made sample, you can try this fragment. It stops the 'root' user from logging in from any networks other than the private network IP blocks.
//block root from logging in except from the private networks
$cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';
$cfg['Servers'][$i]['AllowDeny']['rules'] = array(
    'deny root from all',
    'allow root from localhost',
    'allow root from 10.0.0.0/8',
    'allow root from 192.168.0.0/16',
    'allow root from 172.16.0.0/12',
    );

4.7 Authentication window is displayed more than once, why?

This happens if you are using a URL to start phpMyAdmin which is different than the one set in your $cfg['PmaAbsoluteUri']. For example, a missing "www", or entering with an IP address while a domain name is defined in the config file.

4.8 Which parameters can I use in the URL that starts phpMyAdmin?

When starting phpMyAdmin, you can use the db, pma_username, pma_password and server parameters. This last one can contain either the numeric host index (from $i of the configuration file) or one of the host names present in the configuration file. Using pma_username and pma_password has been tested along with the usage of 'cookie' auth_type.

Browsers or client OS

5.1 I get an out of memory error, and my controls are non-functional, when trying to create a table with more than 14 fields.

We could reproduce this problem only under Win98/98SE. Testing under WinNT4 or Win2K, we could easily create more than 60 fields.
A workaround is to create a smaller number of fields, then come back to your table properties and add the other fields.

5.2 With Xitami 2.5b4, phpMyAdmin won't process form fields.

This is not a phpMyAdmin problem but a Xitami known bug: you'll face it with each script/website that use forms.
Upgrade or downgrade your Xitami server.

5.3 I have problems dumping tables with Konqueror (phpMyAdmin 2.2.2).

With Konqueror 2.1.1: plain dumps, zip and GZip dumps work ok, except that the proposed file name for the dump is always 'tbl_dump.php'. Bzip2 dumps don't seem to work.
With Konqueror 2.2.1: plain dumps work; zip dumps are placed into the user's temporary directory, so they must be moved before closing Konqueror, or else they disappear. GZip dumps give an error message.
Testing needs to be done for Konqueror 2.2.2.

5.4 I can't use the cookie authentication mode because Internet Explorer never stores the cookies.

MS Internet Explorer seems to be really buggy about cookies, at least till version 6. And thanks to Andrew Zivolup we've traced also a PHP 4.1.1 bug in this area!
Then, if you're running PHP 4.1.1, try to upgrade or downgrade... it may work!

5.5 In Internet Explorer 5.0, I get JavaScript errors when browsing my rows.

Upgrade to at least Internet Explorer 5.5 SP2.

5.6 In Internet Explorer 5.0, 5.5 or 6.0, I get an error (like "Page not found") when trying to modify a row in a table with many fields, or with a text field

Your table neither have a primary key nor an unique one, so we must use a long URL to identify this row. There is a limit on the length of the URL in those browsers, and this not happen in Netscape, for example. The workaround is to create a primary or unique key, or use another browser.

5.7 I refresh (reload) my browser, and come back to the welcome page.

Some browsers support right-clicking into the frame you want to refresh, just do this in the right frame.

5.8 With Mozilla 0.9.7 I have problems sending a query modified in the query box.

Looks like a Mozilla bug: 0.9.6 was OK. We will keep an eye on future Mozilla versions.

5.9 With Mozilla 0.9.? to 1.0 and Netscape 7.0-PR1 I can't type a whitespace in the SQL-Query edit area: the page scrolls down.

This is a Mozilla bug (see bug #26882 at BugZilla).

5.10 With Netscape 4.75 I get empty rows between each row of data in a CSV exported file.

This is a known Netscape 4.75 bug: it adds some line feeds when exporting data in octet-stream mode. Since we can't detect the specific Netscape version, we cannot workaround this bug.

5.11 Extended-ASCII characters like German umlauts are displayed wrong.

Please ensure that you have set your browser's character set to the one of the language file you have selected on phpMyAdmin's start page. Alternatively, you can try the auto detection mode that is supported by the recent versions of the most browsers.

5.12 Mac OS X: Safari browser changes special characters to "?".

This issue has been reported by a OS X user, who adds that Chimera, Netscape and Mozilla do not have this problem.

5.13 With Internet Explorer 5.5 or 6, and HTTP authentication type, I cannot manage two servers: I log in to the first one, then the other one, but if I switch back to the first, I have to log in on each operation.

This is a bug in Internet Explorer, other browsers do not behave this way.

5.14 Using Opera6, I can manage to get to the authentication, but nothing happens after that, only a blank screen.

Having $cfg['QueryFrameJS'] set o TRUE, this leads to a bug in Opera6, because it is not able to interpret frameset definitions written by JavaScript. Please upgrade your phpMyAdmin installtion or to Opera7 at least.

5.15 I have display problems with Safari.

Please upgrade to at least version 1.2.3.

5.16 With Internet Explorer, I get "Access is denied" Javascript errors. Or I cannot make phpMyAdmin work under Windows.

Please check the following points:
  • Maybe you have defined your PmaAbsoluteUri setting in config.inc.php to an IP address and you are starting phpMyAdmin with a URL containing a domain name, or the reverse situation.
  • Security settings in IE and/or Microsoft Security Center are too high, thus blocking scripts execution.
  • The Windows Firewall is blocking Apache and MySQL. You must allow HTTP ports (80 or 443) and MySQL port (usually 3306) in the "in" and "out" directions.

5.17 With Firefox, I cannot delete rows of data or drop a database.

Many users have confirmed that the Tabbrowser Extensions plugin they installed in their Firefox is causing the problem.

Using phpMyAdmin

6.1 I can't insert new rows into a table / I can't create a table - MySQL brings up a SQL-error.

Examine the SQL error with care. Often the problem is caused by specifying a wrong field-type.
Common errors include:
  • Using VARCHAR without a size argument
  • Using TEXT or BLOB with a size argument
Also, look at the syntax chapter in the MySQL manual to confirm that your syntax is correct.

6.2 When I create a table, I click the Index checkbox for 2 fields and phpMyAdmin generates only one index with those 2 fields.

In phpMyAdmin 2.2.0 and 2.2.1, this is the way to create a multi-fields index. If you want two indexes, create the first one when creating the table, save, then display the table properties and click the Index link to create the other index.

6.3 How can I insert a null value into my table?

Since version 2.2.3, you have a checkbox for each field that can be null. Before 2.2.3, you had to enter "null", without the quotes, as the field's value. Since version 2.5.5, you have to use the checkbox to get a real NULL value, so if you enter "NULL" this means you want a literal NULL in the field, and not a NULL value (this works in PHP4).

6.4 How can I backup my database or table?

Click on a database or table name in the left frame, the properties will be displayed. Then on the menu, click "Export", you can dump the structure, the data, or both. This will generate standard SQL statements that can be used to recreate your database/table.

You will need to choose "Save as file", so that phpMyAdmin can transmit the resulting dump to your station. Depending on your PHP configuration, you will see options to compress the dump. See also the $cfg['ExecTimeLimit'] configuration variable.

For additional help on this subject, look for the word "dump" in this document.

6.5 How can I restore (upload) my database or table using a dump? How can I run a ".sql" file?

Click on a database name in the left frame, the properties will be displayed. Select "Import" from the list of tabs in the right–hand frame (or "SQL" if your phpMyAdmin version is previous to 2.7.0). In the "Location of the text file" section, type in the path to your dump filename, or use the Browse button. Then click Go.

With version 2.7.0, the import engine has been re–written, if possible it is suggested that you upgrade to take advantage of the new features.

For additional help on this subject, look for the word "upload" in this document.

6.6 How can I use the relation table in Query-by-example?

Here is an example with the tables persons, towns and countries, all located in the database mydb. If you don't have a pma_relation table, create it as explained in the configuration section. Then create the example tables:
CREATE TABLE REL_countries (
    country_code char(1) NOT NULL default '',
    description varchar(10) NOT NULL default '',
    PRIMARY KEY (country_code)
) TYPE=MyISAM;

INSERT INTO REL_countries VALUES ('C', 'Canada');

CREATE TABLE REL_persons (
    id tinyint(4) NOT NULL auto_increment,
    person_name varchar(32) NOT NULL default '',
    town_code varchar(5) default '0',
    country_code char(1) NOT NULL default '',
    PRIMARY KEY (id)
) TYPE=MyISAM;

INSERT INTO REL_persons VALUES (11, 'Marc', 'S', '');
INSERT INTO REL_persons VALUES (15, 'Paul', 'S', 'C');

CREATE TABLE REL_towns (
    town_code varchar(5) NOT NULL default '0',
    description varchar(30) NOT NULL default '',
    PRIMARY KEY (town_code)
) TYPE=MyISAM;

INSERT INTO REL_towns VALUES ('S', 'Sherbrooke');
INSERT INTO REL_towns VALUES ('M', 'Montréal');
To setup appropriate links and display information:
  • on table "REL_persons" click Structure, then Relation view
  • in Links, for "town_code" choose "REL_towns->code"
  • in Links, for "country_code" choose "REL_countries->country_code"
  • on table "REL_towns" click Structure, then Relation view
  • in "Choose field to display", choose "description"
  • repeat the two previous steps for table "REL_countries"
Then test like this:
  • Click on your db name in the left frame
  • Choose "Query"
  • Use tables: persons, towns, countries
  • Click "Update query"
  • In the fields row, choose persons.person_name and click the "Show" tickbox
  • Do the same for towns.description and countries.descriptions in the other 2 columns
  • Click "Update query" and you will see in the query box that the correct joins have been generated
  • Click "Submit query"

6.7 How can I use the "display field" feature?

Starting from the previous example, create the pma_table_info as explained in the configuration section, then browse your persons table, and move the mouse over a town code or country code.

See also FAQ 6.21 for an additional feature that "display field" enables: drop-down list of possible values.

6.8 How can I produce a PDF schema of my database?

First the configuration variables "relation", "table_coords" and "pdf_pages" have to be filled in.

Then you need to think about your schema layout. Which tables will go on which pages?
  • Select your database in the left frame.
  • Choose "Operations" in the navigation bar at the top.
  • Choose "Edit PDF Pages" near the bottom of the page.
  • Enter a name for the first PDF page and click Go. If you like, you can use the "automatic layout," which will put all your linked tables onto the new page.
  • Select the name of the new page (making sure the Edit radio button is selected) and click Go.
  • Select a table from the list, enter its coordinates and click Save.
    Coordinates are relative; your diagram will be automatically scaled to fit the page. When initially placing tables on the page, just pick any coordinates -- say, 50x50. After clicking Save, you can then use the graphical editor to position the element correctly.
  • When you'd like to look at your PDF, first be sure to click the Save button beneath the list of tables and coordinates, to save any changes you made there. Then scroll all the way down, select the PDF options you want, and click Go.
  • Internet Explorer for Windows may suggest an incorrect filename when you try to save a generated PDF. When saving a generated PDF, be sure that the filename ends in ".pdf", for example "schema.pdf". Browsers on other operating systems, and other browsers on Windows, do not have this problem.

6.9 phpMyAdmin is changing the type of one of my columns!

No, it's MySQL that is doing silent column type changing.

6.10 When creating a privilege, what happens with underscores in the database name?

If you do not put a backslash before the underscore, this is a wildcard grant, and the underscore means "any character". So, if the database name is "john_db", the user would get rights to john1db, john2db ...

If you put a backslash before the underscore, it means that the database name will have a real underscore.

6.11 What is the curious symbol ø in the statistics pages?

It means "average".

6.12 I want to understand some Export options.

Structure:
  • "Add DROP TABLE" will add a line telling MySQL to drop the table, if it already exists during the import. It does NOT drop the table after your export, it only affects the import file.
  • "If Not Exists" will only create the table if it doesn't exist. Otherwise, you may get an error if the table name exists but has a different structure.
  • "Add AUTO_INCREMENT value" ensures that AUTO_INCREMENT value (if any) will be included in backup.
  • "Enclose table and field names with backquotes" ensures that field and table names formed with special characters are protected.
  • "Add into comments" includes column comments, relations, and MIME types set in the pmadb in the dump as SQL comments (/* xxx */).
Data:
  • "Complete inserts" adds the column names on every INSERT command, for better documentation (but resulting file is bigger).
  • "Extended inserts" provides a shorter dump file by using only once the INSERT verb and the table name.
  • "Delayed inserts" are best explained in the MySQL manual.
  • "Ignore inserts" treats errors as a warning instead. Again, more info is provided in the MySQL manual, but basically with this selected, invalid values are adjusted and inserted rather than causing the entire statement to fail.

6.13 I would like to create a database with a dot in its name.

This is a bad idea, because in MySQL the syntax "database.table" is the normal way to reference a database and table name. Worse, MySQL will usually let you create a database with a dot, but then you cannot work with it, nor delete it.

6.14 How do I set up the SQL Validator?

To use it, you need a very recent version of PHP, 4.3.0 recommended, with XML, PCRE and PEAR support. On your system command line, run "pear install Net_Socket Net_URL HTTP_Request Mail_Mime Net_DIME SOAP" to get the necessary PEAR modules for usage.
On a more recent pear version, I had problems with the state of Net_DIME being beta, so this single command "pear -d preferred_state=beta install -a SOAP" installed all the needed modules.
If you use the Validator, you should be aware that any SQL statement you submit will be stored anonymously (database/table/column names, strings, numbers replaced with generic values). The Mimer SQL Validator itself, is © 2001 Upright Database Technology. We utilize it as free SOAP service.

6.15 I want to add a BLOB field and put an index on it, but MySQL says "BLOB column '...' used in key specification without a key length".

The right way to do this, is to create the field without any indexes, then display the table structure and use the "Create an index" dialog. On this page, you will be able to choose your BLOB field, and set a size to the index, which is the condition to create an index on a BLOB field.

6.16 How can I simply move in page with plenty editing fields?

You can use Ctrl+arrows (Option+Arrows in Safari) for moving on most pages with many editing fields (table structure changes, row editing, etc.) (must be enabled in configuration - see. $cfg['CtrlArrowsMoving']). You can also have a look at the directive $cfg['DefaultPropDisplay'] ('vertical') and see if this eases up editing for you.

6.17 Transformations: I can't enter my own mimetype! WTF is this feature then useful for?

Slow down :). Defining mimetypes is of no use, if you can't put transformations on them. Otherwise you could just put a comment on the field. Because entering your own mimetype will cause serious syntax checking issues and validation, this introduces a high-risk false-user-input situation. Instead you have to initialize mimetypes using functions or empty mimetype definitions.
Plus, you have a whole overview of available mimetypes. Who knows all those mimetypes by heart so he/she can enter it at will?

6.18 Bookmarks: Where can I store bookmarks? Why can't I see any bookmarks below the query box? What is this variable for?

Any query you have executed can be stored as a bookmark on the page where the results are displayed. You will find a button labeled 'Bookmark this query' just at the end of the page.
As soon as you have stored a bookmark, it is related to the database you run the query on. You can now access a bookmark dropdown on each page, the query box appears on for that database.

Since phpMyAdmin 2.5.0 you are also able to store variables for the bookmarks. Just use the string /*[VARIABLE]*/ anywhere in your query. Everything which is put into the value input box on the query box page will replace the string "/*[VARIABLE]*/" in your stored query. Just be aware of that you HAVE to create a valid query, otherwise your query won't be even able to be stored in the database.
Also remember, that everything else inside the /*[VARIABLE]*/ string for your query will remain the way it is, but will be stripped of the /**/ chars. So you can use:

/*, [VARIABLE] AS myname */

which will be expanded to

, VARIABLE as myname

in your query, where VARIABLE is the string you entered in the input box. If an empty string is provided, no replacements are made.

A more complex example. Say you have stored this query:

SELECT Name, Address FROM addresses WHERE 1 /* AND Name LIKE '%[VARIABLE]%' */

Say, you now enter "phpMyAdmin" as the variable for the stored query, the full query will be:

SELECT Name, Address FROM addresses WHERE 1 AND Name LIKE '%phpMyAdmin%'

You can use multiple occurrences of /*[VARIABLE]*/ in a single query.
NOTE THE ABSENCE OF SPACES inside the "/**/" construct. Any spaces inserted there will be later also inserted as spaces in your query and may lead to unexpected results especially when using the variable expansion inside of a "LIKE ''" expression.
Your initial query which is going to be stored as a bookmark has to yield at least one result row so you can store the bookmark. You may have that to work around using well positioned "/**/" comments.

6.19 How can I create simple LATEX document to include exported table?

You can simply include table in your LATEX documents, minimal sample document should look like following one (assuming you have table exported in file table.tex):
\documentclass{article} % or any class you want
\usepackage{longtable}  % for displaying table
\begin{document}        % start of document
\include{table}         % including exported table
\end{document}          % end of document

6.20 In MySQL 4, I see a lot of databases which are not mine, and cannot access them.

Upgrading to MySQL 4 usually gives users those global privileges: CREATE TEMPORARY TABLES, SHOW DATABASES, LOCK TABLES. Those privileges also enable users to see all the database names. See this bug report.

So if your users do not need those privileges, you can remove them and their databases list will shorten.

6.21 In edit/insert mode, how can I see a list of possible values for a field, based on some foreign table?

You have to setup appropriate links between the tables, and also setup the "display field" in the foreign table. See FAQ 6.6 for an example. Then, if there are 200 values or less in the foreign table, a drop-down list of values will be available. You will see two lists of values, the first list containing the key and the display field, the second list containing the display field and the key. The reason for this is to be able to type the first letter of either the key or the display field.

For 200 values or more, a distinct window will appear, to browse foreign key values and choose one.

6.22 Bookmarks: Can I execute a default bookmark automatically when entering Browse mode for a table?

Yes. If a bookmark has the same label as a table name, it will be executed.

6.23 Export: I heard phpMyAdmin can export Microsoft Excel files, how can I enable that?

Current version does support direct export to Microsoft Excel and Word versions 2000 and newer. If you need export older versions, you can use CSV suitable for Microsoft Excel, which works out of the box or you can try native experimental MS Excel exporter. This export has several problems, most important are limitation of cell content to 255 chars and no support for charsets, so think carefully whether you want to enable this.. For enabling this you need to set $cfg['TempDir'] to place where web server user can write (for example './tmp') and install PEAR module Spreadsheet_Excel_Writer into php include path. The installation can be done by following command:
pear -d preferred_state=beta install -a Spreadsheet_Excel_Writer
First part of switches set we want to install beta version of that module (no stable version available yet) and then we tell pear we want to satisfy dependencies.
If you are running in PHP safe mode, you will have to set in php.ini the safe_mode_include_dir to the directory where your PEAR modules are located, for example:
safe_mode_include_dir = /usr/local/lib/php
To create the temporary directory on a UNIX-based system, you can do:
cd phpMyAdmin
mkdir tmp
chmod o+rwx tmp

6.24 Now that phpMyAdmin supports native MySQL 4.1.x column comments, what happens to my column comments stored in pmadb?

Automatic migration of a table's pmadb-style column comments to the native ones is done whenever you enter Structure page for this table.

phpMyAdmin project

7.1 I have found a bug. How do I inform developers?

Our Bug Tracker is located at http://sf.net/projects/phpmyadmin/ under the Bugs section.

But please first discuss your bug with other users:
http://sf.net/projects/phpmyadmin/ (and choose Forums)

7.2 I want to translate the messages to a new language or upgrade an existing language, where do I start?

Always use the current SVN version of your language file. For a new language, start from english-iso-8859-1.inc.php. If you don't know how to get the SVN version, please ask one of the developers.
Please note that we try not to use HTML entities like &eacute; in the translations, since we define the right character set in the file. With HTML entities, the text on JavaScript messages would not display correctly. However there are some entities that need to be there, for quotes ,non-breakable spaces, ampersands, less than, greater than.
You can then put your translations, as a zip file to avoid losing special characters, on the sourceforge.net translation tracker.
It would be a good idea to subscribe to the phpmyadmin-translators mailing list, because this is where we ask for translations of new messages.

7.3 I would like to help out with the development of phpMyAdmin. How should I proceed?

The following method is preferred for new developers:
  1. fetch the current SVN tree over anonymous SVN:
    svn co https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin
  2. add your stuff
  3. generate patch with your changes: svn diff
  4. put the patch inside the patch tracker of the phpMyAdmin project.
Write access to the SVN tree is granted only to experienced developers who have already contributed something useful to phpMyAdmin.
Also, have a look at the Developers section.

Security

8.1 Where can I get information about the security alerts issued for phpMyAdmin?

Please refer to http://www.phpmyadmin.net/home_page/security.php

Developers Information

phpMyAdmin is Open Source, so you're invited to contribute to it. Many great features have been written by other people and you too can help to make phpMyAdmin a useful tool.
If you're planning to contribute source, please read the following information:
  • All files include libraries/header.inc.php (layout),. libraries/common.lib.php (common functions) and config.inc.php.
    Only configuration data should go in config.inc.php. Please keep it free from other code.
    Commonly used functions should be added to libraries/common.lib.php and more specific ones may be added within a library stored into the libraries sub-directory.
  • Obviously, you're free to use whatever coding style you want. But please try to keep your code as simple as possible: beginners are using phpMyAdmin as an example application.
    As far as possible, we want the scripts to be XHTML1.0 and CSS2 compliant on one hand, they fit the PEAR coding standards on the other hand. Please pay attention to this.
  • Please try to keep up the file-naming conventions. Table-related stuff goes to tbl_*.php, db-related code to db_*.php, server-related tools to server_*.php and so on.
  • Please don't use verbose strings in your code, instead add the string (at least) to english-iso-8859-1.inc.php and print() it out.
  • If you want to be really helpful, write an entry for the ChangeLog.
  • The DBG extension (PHP Debugger DBG) is now supported by phpMyAdmin for developers to better debug and profile their code.
    Please see the $cfg['DBG']* configuration options for more information.
    This is in memoriam of the Space Shuttle Columbia (STS-107) which was lost during its re-entry into Earth's atmosphere and in memory of the brave men and women who gave their lives for the people of Earth.
 

Glossary

From Wikipedia, the free encyclopedia
  • .htaccess - the default name of Apache's directory-level configuration file.
  • Blowfish - a keyed, symmetric block cipher, designed in 1993 by Bruce Schneier.
  • Browser (Web Browser) - a software application that enables a user to display and interact with text, images, and other information typically located on a web page at a website on the World Wide Web.
  • bzip2 - a free software/open source data compression algorithm and program developed by Julian Seward.
  • CGI (Common Gateway Interface) - an important World Wide Web technology that enables a client web browser to request data from a program executed on the Web server.
  • Changelog - a log or record of changes made to a project.
  • Client - a computer system that accesses a (remote) service on another computer by some kind of network.
  • column - a set of data values of a particular simple type, one for each row of the table.
  • Cookie - a packet of information sent by a server to a World Wide Web browser and then sent back by the browser each time it accesses that server.
  • CSV - Comma-seperated values
  • DB - look at Database.
  • database - an organized collection of data.
  • Engine - look at Storage Engines.
  • extension - a PHP module that extends PHP with additional functionality.
  • FAQ (Frequently Asked Questions) - a list of commonly asked question and there answers.
  • Field - one part of divided data/columns.
  • foreign key - a field or group of fields in a database record that point to a key field or group of fields forming a key of another database record in some (usually different) table.
  • FPDF (FreePDF) - the free PDF library
  • GD Graphics Library - a library by Thomas Boutell and others for dynamically manipulating images.
  • GD2 - look at GD Graphics Library.
  • gzip - gzip is short for GNU zip, a GNU free software file compression program.
  • host - any machine connected to a computer network, a node that has a hostname.
  • hostname - the unique name by which a network attached device is known on a network.
  • HTTP (HyperText Transfer Protocol) - the primary method used to transfer or convey information on the World Wide Web.
  • https - a HTTP-connection with additional security measures.
  • IIS (Internet Information Services) - a set of Internet-based services for servers using Microsoft Windows.
  • Index - a feature that allows quick access to the rows in a table.
  • IP (Internet Protocol) - a data-oriented protocol used by source and destination hosts for communicating data across a packet-switched internetwork.
  • IP Address - a unique number that devices use in order to identify and communicate with each other on a network utilizing the Internet Protocol standard.
  • ISAPI (Internet Server Application Programming Interface) - the API of Internet Information Services (IIS).
  • ISP (Internet service provider) - a business or organization that offers users access to the Internet and related services.
  • JPEG - a most commonly used standard method of lossy compression for photographic images.
  • JPG - look at JPEG.
  • Key - look at index.
  • LATEX - a document preparation system for the TEX typesetting program.
  • Mac (Apple Macintosh) - line of personal computers is designed, developed, manufactured, and marketed by Apple Computer.
  • Mac OS X - the operating system which is included with all currently shipping Apple Macintosh computers in the consumer and professional markets.
  • MCrypt - a cryptographic library.
  • mcrypt - the MCrypt PHP extension.
  • MIME (Multipurpose Internet Mail Extensions) - an Internet Standard for the format of e-mail.
  • module - some sort of extension for the Apache Webserver.
  • MySQL - a multithreaded, multi-user, SQL (Structured Query Language) Database Management System (DBMS).
  • mysqli - the improved MySQL client PHP extension.
  • mysql - the MySQL client PHP extension.
  • OpenDocument - open standard for office documents.
  • OS X - look at Mac OS X.
  • PDF (Portable Document Format) - a file format developed by Adobe Systems for representing two dimensional documents in a device independent and resolution independent format.
  • PEAR - the PHP Extension and Application Repository.
  • PCRE (Perl Compatible Regular Expressions) - the perl-compatible regular expression functions for PHP
  • PHP - short for "PHP: Hypertext Preprocessor", is an open-source, reflective programming language used mainly for developing server-side applications and dynamic web content, and more recently, a broader range of software applications.
  • port - a connection through which data is sent and received.
  • RFC - Request for Comments (RFC) documents are a series of memoranda encompassing new research, innovations, and methodologies applicable to Internet technologies.
  • RFC 1952 - GZIP file format specification version 4.3
  • Row (record, tulpel) - represents a single, implicitly structured data item in a table.
  • Server - a computer system that provides services to other computing systems over a network.
  • Storage Engines - handlers for different table types
  • socket - a form of inter-process communication.
  • SSL (Secure Sockets Layer) - a cryptographic protocol which provides secure communication on the Internet.
  • SQL - Structured Query Language
  • table - a set of data elements (cells) that is organized, defined and stored as horizontal rows and vertical columns where each item can be uniquely identified by a label or key or by it?s position in relation to other items.
  • Table type
  • tar - a type of archive file format: the Tape ARchive format.
  • TCP (Transmission Control Protocol) - one of the core protocols of the Internet protocol suite.
  • UFPDF - Unicode/UTF-8 extension for FPDF
  • URL (Uniform Resource Locator) - a sequence of characters, conforming to a standardized format, that is used for referring to resources, such as documents and images on the Internet, by their location.
  • Webserver - A computer (program) that is responsible for accepting HTTP requests from clients and serving them Web pages.
  • XML (Extensible Markup Language) - a W3C-recommended general-purpose markup language for creating special-purpose markup languages, capable of describing many different kinds of data.
  • ZIP - a popular data compression and archival format.
  • zlib - an open-source, cross-platform data compression library by Jean-loup Gailly and Mark Adler.