MySQL installation (rpm) and startup configuration

Source: Internet
Author: User
MySql installation (rpm) and startup configuration installation environment: OS: OracleLinux5.9 installation steps: 1. Unzip the MySql installation package [root @ bakdbservermysql] # tar

MySql installation (rpm) and startup configuration installation environment: OS: Oracle Linux 5.9 installation steps: 1. Unzip the MySql installation package [root @ bakdbserver mysql] # tar

MySql installation (rpm) and startup configuration

Installation environment:

OS: Oracle Linux 5.9

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 -- 1 root 191242240 MySQL-5.5.24-1.rhel5.x86_64.tar 2012-05-28

-Rw-r -- 1 7161 wheel 18204697 2012-04-19 MySQL-client-5.5.24-1.rhel5.x86_64.rpm

-Rw-r -- 1 7161 wheel 3869191 2012-04-19 MySQL-devel-5.5.24-1.rhel5.x86_64.rpm

-Rw-r -- 1 7161 wheel 69218533 2012-04-19 MySQL-embedded-5.5.24-1.rhel5.x86_64.rpm

-Rw-r -- 1 7161 wheel 55049591 2012-04-19 MySQL-server-5.5.24-1.rhel5.x86_64.rpm

-Rw-r -- 1 7161 wheel 2083987 2012-04-19 MySQL-shared-5.5.24-1.rhel5.x86_64.rpm

-Rw-r -- 1 7161 wheel 42805943 2012-04-19 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

[Root @ bakdbserver mysql] # id mysql

Uid = 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 the mysql service on the root user

[Root @ bakdbserver ~] # Service mysql start

Starting MySQL .. [OK]

[Root @ bakdbserver ~] # Ps-ef | grep mysql

Root 17075 1 0 00:00:00 pts/1/bin/sh/usr/bin/mysqld_safe -- datadir =/var/lib/mysql -- pid-file =/var/lib/mysql/ bakdbserver. pid

Mysql 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. pid

Root 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 mysql user of the system to perform routine management of MySQL. To allow 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-configure

Drwxr-xr-x 2 mysql 4096 08-23 charsets

-Rwxr-xr-x 1 mysql 4528 2012-04-19 config. huge. ini

...

-- Because the MySQL database directory is already a mysql user permission, you do not need to modify it.

[Root @ bakdbserver mysql] # cd/var/lib/mysql

[Root @ bakdbserver mysql] # ll

Total 28752

Drwx -- x 2 mysql 4096 08-23 mysql

Drwx ------ 2 mysql 4096 08-23 performance_schema

-Rw-r -- 1 mysql 616 08-23 RPM_UPGRADE_HISTORY

-Rw-r -- 1 mysql 495 08-23 RPM_UPGRADE_MARKER-LAST

Drwxr-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 = mysql

Starting 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_profile

PATH = $ PATH: $ HOME/bin

Export PATH

Export LANG = zh_CN

Export DATADIR =/var/lib/mysql

Export BASEDIR =/usr

Export 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 root

Enter password:

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.