MySql installation (rpm) and startup configuration installation steps: 1. Unzip the MySql installation package
[Root @ bakdbserver mysql] # tar-xf MySQL-5.5.24-1.rhel5.x86_64.tar [root @ bakdbserver mysql] # ll total 373920-rw-r -- r -- 1 root 191242240 2012-05-28 MySQL-5.5.24-1.rhel5.x86_64.tar-rw-r -- r -- 1 7161 wheel 18204697 2012-04-19 MySQL-client-5.5.24-1.rhel5.x86_64.rpm-rw-r -- r -- 1 7161 wheel 3869191 2012-04-19 MySQL-devel-5.5.24-1.rhel5.x86_64.rpm-rw-r -- r -- 1 7161 wheel 69218533 2012-04-19 MySQL-embedded-5.5.24-1.rhel5.x86_64.rpm-rw-r -- r -- 1 7161 wheel 55049591 2012-04-19 MySQL-server-5.5.24-1.rhel5.x86_64.rpm-rw-r -- r -- 1 7161 wheel 2083987 2012-04-19 MySQL-shared-5.5.24-1.rhel5.x86_64.rpm-rw-r -- r -- 1 7161 wheel 42805943 MySQL-test-5.5.24-1.rhel5.x86_64.rpm
2. Create a MySql System Administrator
[root@bakdbserver ~]# groupadd mysql[root@bakdbserver ~]# useradd -g mysql mysql[root@bakdbserver mysql]# id mysqluid=502(mysql) gid=54325(mysql) groups=54325(mysql)
3. Install the MySql rpm package
[root@bakdbserver mysql]# rpm -ivh "*.rpm"Preparing... ########################################### [100%] 1:MySQL-client ########################################### [ 17%] 2:MySQL-devel ########################################### [ 33%] 3:MySQL-embedded ########################################### [ 50%] 4:MySQL-server ########################################### [ 67%] 5:MySQL-shared ########################################### [ 83%] 6:MySQL-test ########################################### [100%]
Uninstall sequence:
[Root @ bakdbserver ~] # Rpm-e MySQL-server-5.5.24-1.rhel5 [root @ bakdbserver ~] # Rpm-e MySQL-embedded-5.5.24-1.rhel5 [root @ bakdbserver ~] # Rpm-e MySQL-shared-5.5.24-1.rhel5 [root @ bakdbserver ~] # Rpm-e MySQL-devel-5.5.24-1.rhel5 [root @ bakdbserver ~] # Rpm-e MySQL-test-5.5.24-1.rhel5 [root @ bakdbserver ~] # Rpm-e MySQL-client-5.5.24-1.rhel5 -- MySql is automatically installed under the mysql user -- try to start mysql service in the root user [root @ bakdbserver ~] # Service mysql startStarting MySQL .. [OK] [root @ bakdbserver ~] # Ps-ef | grep mysqlroot 17075 1 0 00:00:00 pts/1/bin/sh/usr/bin/mysqld_safe -- datadir =/var/lib/mysql -- pid-file =/ var/lib/mysql/bakdbserver. pidmysql 17153 17075 0 00:00:00 pts/1/usr/sbin/mysqld -- basedir =/usr -- datadir =/var/lib/mysql -- plugin-dir =/usr/lib64/mysql /plugin -- user = mysql -- log-error =/var/lib/mysql/bakdbserver. err -- pid-file =/var/lib/mysql/bakdbserver. pidroot 17178 12211 0 00:00:00 pts/1 grep mysql
Install the mysql software in the/usr/share/mysql directory. Create the Mysql database in the/var/lib/mysql directory. description of permission to modify the installation directory: to securely manage MySQL, you should use the mysql user of the system to perform routine management of MySQL. In order to allow mysql users to read and write the installation directory, the permission for installing the MySQL installation directory should be repaired.
[Root @ bakdbserver mysql] # cd/usr/share/mysql [root @ bakdbserver share] # chown-R mysql: mysql. [root @ bakdbserver mysql] # ll total 1324-rwxr-xr-x 1 mysql 1153 2012-04-19 binary-configuredrwxr-xr-x 2 mysql 4096 08-23 charsets-rwxr-xr-x 1 mysql 4528 config. huge. ini... -- because the MySQL database directory is already mysql user permission, therefore, you do not need to modify [root @ bakdbserver mysql] # cd/var/lib/mysql [root @ bakdbserver mysql] # ll total 28752drwx -- x 2 mysql 4096 08-23 mysqldrwx ------ 2 mysql 4096 08-23 performance_schema-rw-r -- r -- 1 mysql 616 08-23 RPM_UPGRADE_HISTORY-rw-r -- r -- 1 mysql 495 08-23 RPM_UPGRADE_MARKER-LASTdrwxr-xr-x 2 mysql 4096 08- 23 test...
5. For security reasons, starting the MySQL server should avoid running the server as the Linux Root User and start the server as the mysql user.
[Root @ bakdbserver mysql] #. /mysql. server start -- user = mysqlStarting MySQL .. [OK] or [root @ bakdbserver mysql] #/usr/bin/mysqld_safe -- user = mysql &
To automatically start the server as a given user when the system starts, you can run/etc/my in the/etc/my directory of the server data. in the [mysqld] Group of the cnf option file, add the user option to specify the user name
-- If the/etc/my. cnf file does not exist, you can manually create [root @ bakdbserver ~] # Vi/etc/my. cnf [mysqld] user = mysql [root @ bakdbserver ~] # Chown mysql: mysql/etc/my. cnf
6. Add environment variables for mysql for ease of management and use. Add environment variables for mysql users.
[mysql@bakdbserver ~]$ vi .bash_profilePATH=$PATH:$HOME/binexport PATHexport LANG=zh_CNexport DATADIR=/var/lib/mysqlexport BASEDIR=/usrexport MYSQL_HOME=$BASEDIR/share/mysql
7. After the root user password of the mysql database is installed, the root password is left blank by default. To ensure security, you must change the root initial password.
[mysql@bakdbserver ~]$ mysqladmin -uroot -p password rootEnter password: