Saturday, May 4, 2013

[Warning] .....because the user was set to 'mysql' earlier on the command line

shell> scripts/mysql_install_db --basedir=/usr/local/demouser  --datadir=/var/lib/demodb --user=demouser --ldata=/var/lib/demodb 

Installing MySQL system tables...


[Warning] Ignoring user change to 'demouser' because the user was set to 'mysql' earlier on the command line


Installation of system tables failed


This is an error that makes you look back to the command you just entered and begin to question yourself. The error is not as it appears. If you are installing MySQL onto a server that already has an installation or once did it is likely that a my.cnf file is currently in place.  This file could be very valid for the active server and it is ok to be left alone in those cases. The fix for this error is to override the defaults and enable the MySQL server to pull from a different file that includes the username you prefer.  You can change the username in the file but it is likely that you are looking to test and do other things, so below is an example of how to get the error above up and running again.





shell> cp support-files/my-small.cnf /etc/demodb.cnf

shell> vi /etc/demodb.cnf
       port             = 3307
       socket         = /tmp/demodb.sock


       user            = demouser 
       pid_file       = /var/lib/demodb/demodb.pid


shell> scripts/mysql_install_db --defaults-file=/etc/demodb.cnf --basedir=/usr/local/demouser  --datadir=/var/lib/demodb --user=demouser --ldata=/var/lib/demodb 



Installing MySQL system tables...
OK
Filling help tables...
OK



Again, if a my.cnf file currently exists the mysql_install_db  will try to use that file. Often in that file a username is set which led to the error "the user was set to 'mysql' earlier on the command line"


shell> chown -R demouser /var/lib/demodb/*
shell> # bin/mysqld_safe --defaults-file=/etc/demouser.cnf --user= demouser  --datadir=/var/lib/demodb/ --port=3307 

# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/demodb.server

shell> # bin/mysql --port=3307 --socket=/tmp/demodb.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.30 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.