Learning Mysql


Configuring a system-wide server installed from tarball or source



Download 4.24 Mb.
View original pdf
Page49/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   45   46   47   48   49   50   51   52   ...   366
Learning MySQL
Configuring a system-wide server installed from tarball or source
For security reasons, it’s a good idea to have the system-wide MySQL server run under its own username and group, rather than the superuser account. First, login as the root user with the su - command, and then create the mysql user group groupadd mysql
46 | Chapter 2:
Installing MySQL

and the mysql user account that’s in the mysql user group useradd --gid mysql mysql
It’s all right if you get a message that the group or user already exists.
Now let’s configure the MySQL files and directories. Change to the directory where you installed MySQL; here, we’ll assume that MySQL is installed in the directory /usr/
local/mysql:
# cd /usr/local/mysql
To create the data directory and initialize the database for the user mysql
, run the mysql_install_db script from the scripts directory under the MySQL directory scripts/mysql_install_db --user=mysql
You should now change the files in the MySQL directory to be owned by root but be in the mysql group chown -recursive root:mysql .
And change the database files in the data directory to be be owned by the mysql user and group chown -recursive mysql:mysql data
We described this use of the chown command in Restricting access to files and directories earlier in this chapter.
You can now start the server to run under the mysql system account by running the mysqld_safe program from the MySQL bin directory bin/mysqld_safe --user=mysql &
The ampersand (&) character tells Linux to run the server in the background so that you can use the shell to do other things. If you don’t add the ampersand at the end,
you won’t seethe shell prompt again until the MySQL server is stopped from another shell window.
The next thing to do is to set a password for the database root account bin/mysqladmin --user=root password the_new_mysql_root_password
You can stop the server by running the command bin/mysqladmin --user=root --password=the_mysql_root_password shutdown
Note that the user root on the Linux system is different from the user root on the
MySQL server, and you don’t need to be logged in as the Linux root user to shutdown the server with mysqladmin
You can also start and stop the server using the mysql.server script that comes in the
support-files directory start the server with support-files/mysql.server start

Download 4.24 Mb.

Share with your friends:
1   ...   45   46   47   48   49   50   51   52   ...   366




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

    Main page