MySQL Server Installer - found 2 repeatable bugs,
and a couple of suggestions
Bill Hernandez
ms at mac-specialist.com
Tue May 13 15:11:20 PDT 2008
Ryan,
========================================================================
THIS IS THE WAY THE INFO IS PROVIDED WHEN mysql IS INSTALLED
( 1 ) Run 'sudo -u root mysql_install_db5'
( 2 ) 'PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !' is
followed on
the next line by '... start the server ...' which is easy to
miss, and if
the user tries to set the password a SOCKET error will be
generated, by
that time the user will be so focused on the SOCKET error, that
he won't
even realize that mysql server is not running, which is what
caused the
socket error to begin with...
( 4 ) Finally, way down at the bottom is '... start the MySQL
daemon ...'
=
=
=
=
=
=
=
=
=
=
========================================================================
THIS IS THE CURRENT OUTPUT OF 'mysql_install_db5' :
$ sudo -u root mysql_install_db5
---> <snip>
--->
---> </snip
---> PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
---> To do so, start the server, then issue the following commands:
---> /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-
password'
---> /opt/local/lib/mysql5/bin/mysqladmin -u root -h eagle.local
password 'new-password'
--->
---> Alternatively you can run:
---> /opt/local/lib/mysql5/bin/mysql_secure_installation
--->
---> which will also give you the option of removing the test
---> databases and anonymous user created by default. This is
---> strongly recommended for production servers.
--->
---> See the manual for more instructions.
--->
---> You can start the MySQL daemon with:
---> cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
=
=
=
=
=
=
=
=
=
=
========================================================================
THE STEPS WOULD BE MUCH EASIER TO FOLLOW THIS WAY
=
=
=
=
=
=
=
=
=
=
========================================================================
( 1 ) Initialize the database :
----------------------------------------------------------------------------------
if you have a problem with 'sudo -u mysql mysql_install_db5' :
----------------------------------------------------------------------------------
$ sudo -u mysql mysql_install_db5
---> <snip>
---> ERROR : shell-init: error retrieving current directory: getcwd:
cannot access parent directories: Permission denied
---> </snip>
----------------------------------------------------------------------------------
you can try 'sudo -u root mysql_install_db5' :
----------------------------------------------------------------------------------
ERROR : This happens if the UserShell for this user is set to '/usr/
bin/false' instead of '/bin/bash'
SOLUTION : Instead of using the mysql user to initialize the database
use root as shown below
----------------------------------------------------------------------------------
$ sudo -u root mysql_install_db5
---> <snip>
---> Installing MySQL system tables...
---> Filling help tables...
---> OK
---> </snip
----------------------------------------------------------------------------------
( 2 ) START the MySQL daemon with:
$ cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
( 3 ) MAKE SURE MySQL SERVER (mysql daemon) is RUNNING
$ ps aux | grep mysql
( 4 ) (NOW) REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
MAKE SURE IN STEP ( 3 ) THAT THE MySQL SERVER IS RUNNING
OTHERWISE YOU WILL GET A SOCKET error, then issue the following
commands:
( A ) PREFERRED METHOD :
$ /opt/local/lib/mysql5/bin/mysql_secure_installation
---> this method will give you the option of removing the test
---> databases and anonymous user created by default. This is
---> strongly recommended for production servers.
( B ) ALTERNATE METHOD : Alternatively you can run:
$ /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
$ /opt/local/lib/mysql5/bin/mysqladmin -u root -h eagle.local password
'new-password'
---> See the manual for more instructions.
=
=
=
=
=
=
=
=
=
=
========================================================================
Now, all that having been said...
I have written a fairly lengthy shell script that allows me to delete
'/opt' completely, and :
( 1 ) completely installs, apache2, php, pgsql, mysql, openssl, etc.
plus all the support stuff
( 2 ) creates a central repository if it doesn't already exist for all
the
'.conf, .ini, sites, sites_disabled, daemons, database backups,
etc' within the
'/' directory structure, instead of being in several places
within the '/opt' directories.
( 3 ) It then sets up, and initializes, apache2, php, pgsql, mysql
which creates either new,
or uses existing http.conf, mod_php.conf, php.ini, my.cnf.
It then creates all the appropriate symlinks so that everything
works as it should.
Finally,it initializes the databases and imports db data from
backups.
I've been working on this for a while off an on, and it makes deleting
'/opt' and starting
over a piece of cake. I have automated everything except for the mysql
initialization part.
The mysql portion has become very very simple for me to do manually,
since I have now done
this several times, but I have found a couple of bugs in the mysql
install, which are
repeatable, and should be fairly easy to fix.
I will list the bugs I have found below :
----------------------------------------------------------------------------------
BUGS :
----------------------------------------------------------------------------------
( 1 ) after installing mysql, I initialized the database
----------------------------------------------------------------------------------
$ sudo port -v install mysql5 +server
$ sudo -u root mysql_install_db5
----------------------------------------------------------------------------------
( 2 ) I then tried to start mysql server
----------------------------------------------------------------------------------
[2008.13.05](08:32AM) -> [roscoe] ~ $ sudo /opt/local/lib/mysql5/bin/
mysqld_safe &
---> [1] 335
--->
---> Starting mysqld daemon with databases from /opt/local/var/db/mysql5
---> STOPPING server from pid file /opt/local/var/db/mysql5/
eagle.local.pid
--->
---> ERROR : SHUTDOWN
---> 080513 08:33:02 mysqld ended
--->
---> [1]+ Done sudo /opt/local/lib/mysql5/bin/
mysqld_safe
----------------------------------------------------------------------------------
( 3 ) checked to see if was running, or just kidding ?
----------------------------------------------------------------------------------
[2008.13.05](08:40AM) -> [roscoe] ~ $ ps aux | grep mysql
---> roscoe 396 0.0 0.0 599740 384 s001 R+ 8:40AM
0:00.00 grep mysql
----------------------------------------------------------------------------------
( 4 ) So I took a look at the log, and it appears that mysql can't
find '/opt/local/lib/mysql5/share/mysql5/mysql/english/errmsg.sys'
----------------------------------------------------------------------------------
[2008.13.05](08:40AM) -> [roscoe] ~ $ sudo cat /opt/local/var/db/
mysql5/eagle.local.err
---> Password:
--->
---> 080502 00:46:58 mysqld ended
--->
---> 080513 08:33:02 mysqld started
---> 080513 8:33:02 [ERROR] Can't find messagefile '/opt/local/lib/
mysql5/share/mysql5/mysql/english/errmsg.sys'
---> 080513 8:33:02 [ERROR] Aborting
--->
---> 080513 08:33:02 mysqld ended
----------------------------------------------------------------------------------
( 5 ) So I decide to find where it really lives
----------------------------------------------------------------------------------
[2008.13.05](09:04AM) -> [roscoe] ~ $ sudo find /opt/local -name
errmsg.sys | grep english
---> /opt/local/share/mysql5/mysql/english/errmsg.sys
----------------------------------------------------------------------------------
( 6 ) I work my way down the tree until I find
----------------------------------------------------------------------------------
[2008.13.05](09:12AM) -> [roscoe] ~ $ open /opt/local/lib/mysql5/share/
mysql5/mysql/
---> The file /opt/local/lib/mysql5/share/mysql5/mysql does not exist.
[2008.13.05](09:12AM) -> [roscoe] ~ $ open /opt/local/lib/mysql5/share/
mysql5/
---> The file /opt/local/lib/mysql5/share/mysql5 does not exist.
[2008.13.05](09:12AM) -> [roscoe] ~ $ open /opt/local/lib/mysql5/share/
---> The file /opt/local/lib/mysql5/share does not exist.
[2008.13.05](09:12AM) -> [roscoe] ~ $ open /opt/local/lib/mysql5/
---> FOUND IT...
----------------------------------------------------------------------------------
( 6 ) Hallellujah, I found where the symlink needs to go..
CREATE THE SYMLINK TO FIX THE STARTUP PROBLEM
----------------------------------------------------------------------------------
[2008.13.05](09:13AM) -> [roscoe] ~ $ sudo ln -s /opt/local/share /opt/
local/lib/mysql5/share
----------------------------------------------------------------------------------
TRY STEP ( 2 ) AGAIN - this time it works
( 2 ) Try the re-start of mysql server
----------------------------------------------------------------------------------
[2008.13.05](09:16AM) -> [roscoe] ~ $ sudo /opt/local/lib/mysql5/bin/
mysqld_safe &
---> [1] 617
---> Starting mysqld daemon with databases from /opt/local/var/db/mysql5
----------------------------------------------------------------------------------
TRY STEP ( 3 ) AGAIN - this time it works
( 3 ) Check again to see iv=f the broken link fixed the problem ?
----------------------------------------------------------------------------------
[2008.13.05](09:16AM) -> [roscoe] ~ $ ps aux | grep mysql
---> mysql 647 0.0 0.7 644536 15144 s000 S 9:16AM
0:00.11
---> /opt/local/libexec/mysqld --basedir=/opt/local/lib/mysql5
---> --datadir=/opt/local/var/db/mysql5 --user=mysql --pid-file=/opt/
local/var/db/mysql5/eagle.local.pid
---> --port=3306 --socket=/opt/local/var/run/mysql5/mysqld.sock
---> root 617 0.0 0.0 600172 716 s000 S 9:16AM
0:00.02 /bin/sh
---> /opt/local/lib/mysql5/bin/mysqld_safe
---> roscoe 655 0.0 0.0 599740 388 s000 S+ 9:16AM
0:00.00 grep mysql
[2008.13.05](09:16AM) -> [roscoe] ~ $
----------------------------------------------------------------------------------
( 7 ) NOW that mysql server is running, let's try the
'mysql_secure_installation'..
----------------------------------------------------------------------------------
[2008.13.05](09:19AM) -> [roscoe] ~ $ sudo find /opt -name
mysql_secure_installation
---> /opt/local/lib/mysql5/bin/mysql_secure_installation
[2008.13.05](09:19AM) -> [roscoe] ~ $ sudo /opt/local/lib/mysql5/bin/
mysql_secure_installation
---> NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
---> SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
--->
---> In order to log into MySQL to secure it, we'll need the current
---> password for the root user. If you've just installed MySQL, and
---> you haven't set the root password yet, the password will be blank,
---> so you should just press enter here.
--->
---> Enter current password for root (enter for none):
---> /opt/local/lib/mysql5/bin/mysql_secure_installation: line 42:
mysql: command not found
---> OK, successfully used password, moving on...
--->
---> Setting the root password ensures that nobody can log into the
MySQL
---> root user without the proper authorisation.
--->
---> Set root password? [Y/n] y
---> New password:
---> Re-enter new password:
--->
--->
----------------------------------------------------------------------------------
---> SERIOUS ERROR : mysql_secure_installation: line 42: mysql:
command not found
--->
----------------------------------------------------------------------------------
---> /opt/local/lib/mysql5/bin/mysql_secure_installation: line 42:
mysql: command not found
---> Password update failed!
[2008.13.05](09:20AM) -> [roscoe] ~ $
----------------------------------------------------------------------------------
SOLUTION TO : mysql_secure_installation: line 42: mysql: command not
found
----------------------------------------------------------------------------------
THE EXISTING PATH IN ~/.bash_profile WAS :
export PATH="/opt/local/sbin:$PATH"
export PATH="/opt/local/bin:$PATH"
THE ERROR WAS FIXED BY ADDING :
export PATH="/opt/local/lib/mysql5/bin:$PATH"
IMPORTANT : Apparently one of the commands that
mysql_secure_installation requires does not have a symlink in '/opt/
local/bin', thus causing the "command not found" error.
Adding '/opt/local/lib/mysql5/bin' to the $PATH might only cause a
problem if you have multiple versions or instances of mysql, such as
one in '/usr/local/mysql'.
Notice that when you compare the two directories, all the symlinks in
'/opt/local/bin' have the same name as the actual items in '/opt/local/
lib/mysql5/bin', except the symlinks all end in '5', so '/opt/local/
lib/mysql5/bin/mysql_secure_installation' actually symlinks to '/opt/
local/bin/mysql_secure_installation5', all in the spirit of preventing
problems if you have a mysql4, and mysql5 installation on the same
machine.
But in my case this will not be a problem, since I also renamed '/usr/
local/mysql' to '/usr/local/xx_mysql' and removed '/usr/local/mysql'
from the $PATH in '~/.bash_profile'.
----------------------------------------------------------------------------------
TRY STEP ( 2 ) AGAIN - this time it works
( 7 ) NOW that we added '/opt/local/lib/mysql5/bin' to the PATH, let's
try the 'mysql_secure_installation'..
----------------------------------------------------------------------------------
[2008.13.05](09:31AM) -> [roscoe] ~ $ mysql_secure_installation
---> NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
---> SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
--->
---> In order to log into MySQL to secure it, we'll need the current
---> password for the root user. If you've just installed MySQL, and
---> you haven't set the root password yet, the password will be blank,
---> so you should just press enter here.
--->
---> Enter current password for root (enter for none):
---> OK, successfully used password, moving on...
--->
---> Setting the root password ensures that nobody can log into the
MySQL
---> root user without the proper authorisation.
--->
---> Set root password? [Y/n] y
---> New password:
---> Re-enter new password:
---> Password updated successfully!
---> Reloading privilege tables..
---> ... Success!
--->
---> By default, a MySQL installation has an anonymous user, allowing
anyone
---> to log into MySQL without having to have a user account created for
---> them. This is intended only for testing, and to make the
installation
---> go a bit smoother. You should remove them before moving into a
---> production environment.
--->
---> Remove anonymous users? [Y/n] y
---> ... Success!
--->
---> Normally, root should only be allowed to connect from
'localhost'. This
---> ensures that someone cannot guess at the root password from the
network.
--->
---> Disallow root login remotely? [Y/n] y
---> ... Success!
--->
---> By default, MySQL comes with a database named 'test' that anyone
can
---> access. This is also intended only for testing, and should be
removed
---> before moving into a production environment.
--->
---> Remove test database and access to it? [Y/n] y
---> - Dropping test database...
---> ... Success!
---> - Removing privileges on test database...
---> ... Success!
--->
---> Reloading the privilege tables will ensure that all changes made
so far
---> will take effect immediately.
--->
---> Reload privilege tables now? [Y/n] y
---> ... Success!
--->
---> Cleaning up...
--->
---> All done! If you've completed all of the above steps, your MySQL
---> installation should now be secure.
--->
---> Thanks for using MySQL!
---> GREAT !
[2008.13.05](09:32AM) -> [roscoe] ~ $
----------------------------------------------------------------------------------
( 8 ) See if mysql server works ?
----------------------------------------------------------------------------------
[2008.02.04](02:47AM) -> [roscoe] ~ $ mysql5 -u root -p
---> Enter password:
---> Welcome to the MySQL monitor. Commands end with ; or \g.
---> Your MySQL connection id is 3
---> Server version: 5.0.51-log Source distribution
--->
---> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE IF NOT EXISTS users_db ;
---> Query OK, 1 row affected (0.03 sec)
--->
---> mysql> show databases ;
---> +--------------------+
---> | Database |
---> +--------------------+
---> | information_schema |
---> | mysql |
---> | test |
---> | users_db |
---> +--------------------+
---> 4 rows in set (0.00 sec)
mysql> quit
---> Bye
----------------------------------------------------------------------------------
( 8 ) Import the mysql backup data ?
----------------------------------------------------------------------------------
[2008.02.04](02:54AM) -> [roscoe] ~ $ mysql5 -u root -p users_db < /
Users/roscoe/Desktop/users_db.sql
---> Enter password:
[2008.02.04](02:55AM) -> [roscoe] ~ $ mysql5 -u root -p
---> Enter password:
---> Welcome to the MySQL monitor. Commands end with ; or \g.
---> Your MySQL connection id is 5
---> Server version: 5.0.51-log Source distribution
--->
---> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use users_db ;
---> Database changed
mysql> show tables ;
---> +--------------------+
---> | Tables_in_users_db |
---> +--------------------+
---> | users |
---> | <snip> |
---> | |
---> | </snip> |
---> | quotes |
---> +--------------------+
---> 18 rows in set (0.00 sec)
LIFE IS SWELL, MySQL WORKS...
Hopefully you guys can fix the two bugs in the installer...
One last thing : I have to use 'cat' or open '/opt/local/var/db/mysql5/
roscoe.local.err' using an editor
$ sudo cat /opt/local/var/db/mysql5/roscoe.local.err
It would be much easier if the error log had an extension of '.log',
then if you double clicked on it, the 'Console.app' would open it,
which is more of a standard way of accessing logs for me...
Bill Hernandez
Plano, Texas
More information about the macports-users
mailing list