Mysql Server Question

Tim Frost timfrost at xtra.co.nz
Tue Nov 22 00:59:57 UTC 2005


On Sun, 2005-11-20 at 17:29 -0600, Wade Smart wrote: 
> 11202005 1725 GMT-5
> 
> Tim - a question. Im still really new to linux so bear with me. My book 
> on mysql says -> mysql will be installed as root but for security 
> reasons dont run it as such. Its best to change the owner and group to 
> something like mysqladm and mysqlgrp.
> 

Agreed.  But that affects the running server.  You first need to
initialise the database.  That is what the mysql_install_db script is
doing.

Incidentally, I installed the mysql-server package (and dependencies),
using synaptic, on my breezy desktop, and find that:
* a special user, mysql, was created
* it automatically initialised the database.
* the server runs with parameter 
      --user=mysql
* all files and directories are owned by the mysql user


So, if you installed the ubuntu packages, you should have the database
fully functional, with the correct permissions.  And the base tables
will have been correctly created by running the mysql_install_db as user
mysql.  Check the files and directories under /var/lib/mysql.  My system
has the following (notice that the directories /var/.lib/mysql/mysql
and /var/lib/mysql/test have *group* root - indicating that they were
created during the install, and had the owner changed):
tim at marvin:~$ ls -ld /var/lib/mysql/
drwxr-xr-x  4 mysql mysql 4096 2005-11-21 19:57 /var/lib/mysql/
tim at marvin:~$ ls -l /var/lib/mysql/
total 20556
-rw-rw----  1 mysql mysql    25088 2005-11-21 15:08
ib_arch_log_0000000000
-rw-rw----  1 mysql mysql 10485760 2005-11-21 19:57 ibdata1
-rw-rw----  1 mysql mysql  5242880 2005-11-21 19:57 ib_logfile0
-rw-rw----  1 mysql mysql  5242880 2005-11-21 15:08 ib_logfile1
drwxr-xr-x  2 mysql root      4096 2005-11-21 15:07 mysql
drwxr-xr-x  2 mysql root      4096 2005-11-21 15:07 test
tim at marvin:~$ ls -l /var/lib/mysql/mysql/
total 100
-rw-rw----  1 mysql mysql 8778 2005-11-21 15:07 columns_priv.frm
-rw-rw----  1 mysql mysql    0 2005-11-21 15:07 columns_priv.MYD
-rw-rw----  1 mysql mysql 1024 2005-11-21 15:07 columns_priv.MYI
-rw-rw----  1 mysql mysql 9088 2005-11-21 15:07 db.frm
-rw-rw----  1 mysql mysql    0 2005-11-21 15:07 db.MYD
-rw-rw----  1 mysql mysql 1024 2005-11-21 15:07 db.MYI
-rw-rw----  1 mysql mysql 8641 2005-11-21 15:07 func.frm
-rw-rw----  1 mysql mysql    0 2005-11-21 15:07 func.MYD
-rw-rw----  1 mysql mysql 1024 2005-11-21 15:07 func.MYI
-rw-rw----  1 mysql mysql 9064 2005-11-21 15:07 host.frm
-rw-rw----  1 mysql mysql    0 2005-11-21 15:07 host.MYD
-rw-rw----  1 mysql mysql 1024 2005-11-21 15:07 host.MYI
-rw-rw----  1 mysql mysql 8877 2005-11-21 15:07 tables_priv.frm
-rw-rw----  1 mysql mysql    0 2005-11-21 15:07 tables_priv.MYD
-rw-rw----  1 mysql mysql 1024 2005-11-21 15:07 tables_priv.MYI
-rw-rw----  1 mysql mysql 9806 2005-11-21 15:07 user.frm
-rw-rw----  1 mysql mysql  156 2005-11-21 19:57 user.MYD
-rw-rw----  1 mysql mysql 2048 2005-11-21 19:57 user.MYI


If the tables in /var/lib/mysql/mysql are missing, you need to run the
mysql_install_db as user mysql:
sudo -i                  # gets a shell as root
su mysql                 # should give a shell as user mysql
sh mysql_install_db     


Tim





More information about the ubuntu-users mailing list