Learning Mysql


The MySQL Server Daemon | 381



Download 4.24 Mb.
View original pdf
Page347/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   343   344   345   346   347   348   349   350   ...   366
Learning MySQL
The MySQL Server Daemon | 381

superuser, which is dangerous. The user option tells mysqld what user account to run under. It’s a good idea to create an account with the name mysql
, with access permissions for only the MySQL directories, and set the server to run under that username. Don’t forget that this user should be able to read and write files in the
MySQL data and temporary directories. If you don’t specify the username, most
MySQL scripts will automatically try to use your operating system account name as the value for the username.
Examples
Let’s look at how you might use these options in practice. Consider the case where we need to run multiple servers on a single host each server must have a different port,
socket, and process ID file. If we want the servers to keep logs, the logfiles for each server should be different as well. For example, if we’ve installed MySQL under Linux or Mac OS X in the directory /usr/local/mysql and want to run the server under the mysql account—with the database, log, and temporary files under the /tmp/mysql directory we could start the server with the command (all on one line mysqld_safe \
--user=mysql \
-port \
--socket=/tmp/mysql/server1.sock \
--basedir=/usr/local/mysql \
--datadir=/tmp/mysql/data \
--tmpdir=/tmp/mysql/tmp \
--log=/tmp/mysql/logs/server1.main.log \
--log-error=/tmp/mysql/logs/server1.error.log \
--pid-file=/tmp/mysql/logs/server1.pid
Instead of typing in the settings at the command line, we can specify the required values in an options file as:
[mysqld]
user= mysql port socket /tmp/mysql/server1.sock basedir= /usr/local/mysql datadir= /tmp/mysql/data tmpdir= /tmp/mysql/tmp
# log server messages to:
log= /tmp/mysql/logs/server1.main.log
# log errors to this file:
log-error=/tmp/mysql/logs/server1.error.log pid-file= /tmp/mysql/logs/server1.pid
We described how to use options files in Chapter 11. Note that since these are really options to the mysqld program, these options are listed under the mysqld group. Options specific to mysqld_safe can be listed under the mysqld_safe group.

Download 4.24 Mb.

Share with your friends:
1   ...   343   344   345   346   347   348   349   350   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page