Miscellaneous: Mysql: Change the location of mysql databases

(last edit: 2001-03-18) You want to change the location of the mysql databases which is by default /var/db/mysql. safe_mysqld If you start the mysql deamon with '/usr/local/bin/safe_mysqld' than you can just edit this script and change the variable (it's in the begining of the script) 'DATADIR'. mysqld If you start the mysql deamon with 'mysqld': <http://www.mysql.com/php/manual.php?section=Option_files> Make a 'my.cnf' file, put it in /usr/local/etc and make sure it looks like this: [client] port = 3306 socket = /tmp/mysql.sock # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking set-variable = key_buffer=16M set-variable = max_allowed_packet=1M set-variable = thread_stack=128K datadir = [datadir] # Start logging log [mysqldump] quick set-variable = max_allowed_packet=16M [mysql] no-auto-rehash [isamchk] set-variable = key_buffer=16M MySQL reads default options from the following files on Unix: Filename Purpose -------------------------------------------- /etc/my.cnf Global options DATADIR/my.cnf Server-specific options ~/.my.cnf User-specific options The following programs support option files: mysql, mysqladmin, mysqld, mysqldump, mysqlimport, mysql.server, myisamchk, myisampack. You can use option files to specify any long option that a program supports! Run the program with --help to get a list of available options. An option file can contain lines of the following forms: #comment Comment lines start with `#' or `;'. Empty lines are ignored. [group] group is the name of the program or group for which you want to set options. After a group line, any option or set-variable lines apply to the named group until the end of the option file or another group line is given. option=value This is equivalent to --option=value on the command line. set-variable = variable=value This is equivalent to --set-variable variable=value on the command line. This syntax must be used to set a mysqld variable. The client group allows you to specify options that apply to all MySQL clients (not mysqld). This is the perfect group to use to specify the password you use to connect to the server. (But make sure the option file is readable and writable only to yourself.) Note that for options and values, all leading and trailing blanks are automatically deleted. You may use the escape sequences `\b', `\t', `\n', `\r', `\\' and `\s' in your value string (`\s' == blank). If you have a source distribution, you will find sample configuration files named `my-xxxx.cnf' in the `support-files' directory. If you have a binary distribution, look in the `DIR/share/mysql' directory, where DIR is the pathname to the MySQL installation directory (typically `/usr/local'). See mysqld --help for more options: Usage: ./mysqld [OPTIONS] -b, --basedir=path Path to installation directory. All paths are usually resolved relative to this --big-tables Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors) --bind-address=IP Ip address to bind to --bootstrap Used by mysql installation scripts --chroot=path Chroot mysqld daemon during startup -h, --datadir=path Path to the database root --enable-locking Enable system locking -T, --exit-info Print some debug info at exit -?, --help Display this help and exit -L, --language=... Client error messages in given language. May be given as a full path -l, --log[=file] Log connections and queries to file --log-update[=file] Log updates to file.# where # is a unique number if not given. --log-isam[=file] Log all isam changes to file --log-long-format Log some extra information to update log --low-priority-insert Inserts has lower priority than selects --pid-file=path Pid file used by safe_mysqld -P, --port=... Port number to use for connection -n, --new Use very new possible 'unsafe' functions -o, --old-protocol Use the old (3.20) protocol --one-thread Only use one thread (for debugging under Linux) -O, --set-variable var=option Give a variable an value. --help lists variables -Sg, --skip-grant-tables Start without grant tables. This gives all users FULL ACCESS to all tables! --safe-mode Skip some optimize stages (for testing) --skip-locking Don't use system locking. To use isamchk one has to shut down the server. --skip-name-resolve Don't resolve hostnames. All hostnames are IP's or 'localhost' --skip-networking Don't allow connection with TCP/IP. --skip-new Don't use new, possible wrong routines. --skip-host-cache Don't cache host names --skip-thread-priority Don't give threads different priorities. --socket=... Socket file to use for connection -t, --tmpdir=path Path for temporary files -u, --user=user_name Run mysqld daemon as user -V, --version output version information and exit

Click here to go back to the index.