MySql installation (rpm) and startup configuration _ MySQL

Source: Internet
Author: User
MySql installation (rpm) and startup configuration bitsCN.com

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 mysql software in the/usr/share/mysql directory.

The Mysql database is created under the/var/lib/mysql directory.

4. modify the installation directory permission

Note:

To securely manage MySQL, you should use the system's mysql proprietary users for daily management of MySQL. to enable mysql users to read and write the installation directory, you should repair the permission for the MySQL installation directory.

[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. start the MySQL server

For security reasons, you should avoid running the server as a Linux root user and start the server as a 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

To facilitate management and use, add environment variables to the mysql User.

[mysql@bakdbserver ~]$ vi .bash_profilePATH=$PATH:$HOME/binexport PATHexport LANG=zh_CNexport DATADIR=/var/lib/mysqlexport BASEDIR=/usrexport MYSQL_HOME=$BASEDIR/share/mysql

7. modify the root user password of the mysql database

After the installation is complete, the root password is blank by default. to ensure security, you must change the root initial password.

[mysql@bakdbserver ~]$ mysqladmin -uroot -p password rootEnter password:

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.