|
MySQL: MySQL user accounts | MySQL Console | MySQL phpMyAdmin | MySQL Extra Database | MySQL Lost Password | MySQL Error 1067 |
|
MySQL: General information. |
Hosting separate user accounts on your MySQL server requires a properly configured MySQL user management system and the use of phpMyAdmin-advanced authentication.
While it sounds like a complex task, in reality it is extremely easy because all the components are inherently in place. The Uniform Server has phpMyAdmin set up initally for local access by user root. This is easily changed to provide a central copy for users to access via the Internet and maintain their individual databases.
Before diving in, it is worth looking at a little MySQL history. This helps in understanding why The Uniform Server changed the executable name.
I have included this section to show that there were actually several versions of the MySQL server to choose from:
After installing full versions of MySQL, all the above programs are located in the bin directory. Use mysql-opt for Win98x/ME and mysqld-nt on Windows NT/2000/XP. Actually, don't use these versions any more, except to do archival or laboratory studies.
When MySQL five series was introduced, support for Windows 95/98/ME and older versions were dropped. The following versions are supported: Windows operating system 2000, XP, Windows Server 2003, Vista and Windows 7. The number of programs were reduced accordingly:
Uniform Server
If you look in folder *\usr\local\mysql\bin you may be surprised to find the server is named mysqld-opt.exe! In reality it is mysqld-nt.exe. It was renamed to allow backwards compatibility with older plugins and scripts.
The essential point is if you want to upgrade the MySQL server yourself, be sure to use the correct file and rename it accordingly.
Now let's return to providing our users with control and access to their MySQL accounts using phpMyAdmin.
MySQL management is straightforward. Every user, with the exception of root (super user), has global select privileges disabled. Each user must have a name and a corresponding password. To complete the set-up, assign each user one or more databases to access and assign the appropriate privileges.
That covers the management system. To set-up each user account you can use either MySQL console or phpMyAdmin. Click the appropriate link for details. Below is a summary for using phpMyAdmin. After this we'll see how to install a central copy of phpMyAdmin for your users to access on-line.
Check the phpMyAdmin page for more details including images.
Start servers and phpMyAdmin:
Create databases:
Create user accounts:
Refresh the MySQL grant tables:
At the bottom of the User overview page (home > privileges) you will see the following statement:
"phpMyAdmin gets the users' privileges directly from MySQL's privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should reload the privileges before you continue."
Click on reload the privileges link contained in the above statement. This executes the query
SQL query:
FLUSH PRIVILEGES ;
instructing the MySQL server to take another look at the user tables and hence puts all of your new users and privileges into operation.
Authentication has been built into phpMyAdmin since version 2.0.3 and uses the following procedure:
This allows users to log into phpMyAdmin and modify their own databases.
For security reasons, The Uniform Server hides phpMyAdmin from external users; access is limited to localhost. Using a copy of this with minor changes allows users to administer their own databases over the Internet. A central copy of phpMyAdmin is placed in the root folder with authentication enabled as follows:
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = implode ('', file ('../mysql_password')); // MySQL password (only needed
// with 'config' auth_type)
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)? $cfg['Servers'][$i]['user'] = ''; // MySQL user $cfg['Servers'][$i]['password'] = ''; //MySQL password (only needed with 'config' auth_type)
Testing: Type the following http://localhost/phpMyAdmin/ into your browser. You will be challenged to enter name and password.
Enter user root and the password you set for the MySQL server. You will now have access to phpMyAdmin.
Note: Each user must have a different name and password.
You are STANDING OUTSIDE NAKED if you put your servers online leaving MySQL account root with password root! Kiss your MySQL server goodbye. It will be hacked and attacked.
You are the only one that should know your root password! Remember, the server defaults to root so everyone knows this. Please check out the security checklist page and change the root password according to the instructions on that page.
One final touch is to copy the file .htaccess (the one contained in your root folder will do) into the folder phpMyAdmin and edit its contents:
Delete all the lines and add this:
IndexIgnore *
This prevents viewing of any folders by a browser in phpMyAdmin that do not contain an index page.
With your servers online, type into to your browser http://your_domain/phpmyadmin/ and check that everything works.
For example http://www.name.dyndns.org/phpMyAdmin/
Well that about wraps it up for user accounts on a MySQL server -- easy to implement. Even if you are not going to host user accounts, it is still worth reading the phpMyAdmin page to get a feel for its power. Remember, you can cobble The Uniform Server to your hearts content. When it becomes irretrievably broken, just delete it and install a clean version.
| |
Ric |