and the mysql user account that’s in the mysql user group
useradd --gid mysql mysqlIt’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/mysqlTo 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=mysqlYou 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 dataWe 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_passwordYou can stop the
server by running the command bin/mysqladmin --user=root --password=the_mysql_root_password shutdownNote 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 mysqladminYou 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 startShare with your friends: