Detailed steps for installing MySQL5.1 in Linux

Source: Internet
Author: User
Tags mysql free
1, download MySQL installation-free version of the binary software (do not compile) File Format: MYSQL-VERSION-OS.tar.gz2, create a MySQL group, create a MySQL user and add to the mysql group (different versions of Unix, the syntax of groupadd and useradd may be slightly different .) # Groupaddmysql # useradd-gmysqlmysql3, enter the directory u

1, download MySQL free installation version/binary version of the software (do not compile) File Format: MYSQL-VERSION-OS.tar.gz 2, create a MySQL group, create a MySQL user and add to the mysql group (different versions of Unix, the syntax of groupadd and useradd may be slightly different .) # Groupadd mysql # useradd-g mysql 3. Enter the/u directory.

1. Download MySQL installation-free/binary software (No compilation required)

File Format: MYSQL-VERSION-OS.tar.gz

2. Create a MySQL group, create a MySQL user, and add the user to the mysql group.

(In Unix of different versions, groupadd and useradd syntaxes may be slightly different .)

# Groupadd mysql

# Useradd-g mysql

3. Enter the/usr/local directory, decompress the installation-free version, and create a soft link named mysql in this directory.

# Cd/usr/local

# Gunzip </path/to/MYSQL-VERSION-OS.tar.gz | tar xvf-

(This command creates a new directory named MYSQL-VERSION-OS under this directory .)

(Gunzip is no longer needed when using GNU tar. You can directly use the following command to unpack and extract and distribute the package:

#> Tar zxvf/path/to/mysql-VERSION-OS.tar.gz)

# Ln-s MYSQL-VERSION-OS mysql

4. Add a MySQL configuration file

If you want to set an option file, use one of the support-files directories as the template. There are four template files in this directory, which are customized based on the memory of different machines.

# Cp support-files/my-medium.cnf/etc/my. cnf

(You may need to run these commands with the root user .)

5. Set the directory access permission. Use mysql_install_db to create a MySQL authorization table for initialization, and set the mysql and root account access permissions.

# Cd mysql

# Chown-R mysql.

# Chgrp-R mysql.

# Scripts/mysql_install_db-user = mysql

# Chown-R root.

# Chown-R mysql data

(Note that the "." symbol in the preceding command cannot be fewer .)

6. Run MySQL

# Bin/mysqld_safe-user = mysql &

(If there is no problem, a prompt like this should appear:

[1] 42264

# Starting mysqld daemon with databases from/usr/local/mysql/var

If a statement such as mysql ended is displayed, it indicates that Mysql is not started normally. You can find the problem in log. The Log file is usually configured in/etc/my. cnf.

Most problems are caused by incorrect permission settings. )

7. Set the root password. The default installation password is blank. To ensure security, you need to change the password.

#/Usr/local/mysql/bin/mysqladmin-uroot password yourpassword

8. Copy a script in the compilation directory and set automatic start upon startup.

# Cp support-files/mysql. server/etc/rc. d/init. d/mysqld

# Chmod 700/etc/init. d/mysqld

# Chkconfig-add mysqld

# Chkconfig-level 345 mysqld on

9. Start the mysqld service

# Service mysqld start

10. Check whether port 3306 is enabled. Make sure to open the port in the firewall.

# Netstat-atln

Installation-free/binary basic commands:

Shell> groupadd mysql

Shell> useradd-g mysql

Shell> cd/usr/local

Shell> gunzip </PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf-

Shell> ln-s FULL-PATH-TO-MYSQL-VERSION-OS mysql

Shell> cd mysql

Shell> chown-R mysql.

Shell> chgrp-R mysql.

Shell> scripts/mysql_install_db-user = mysql

Shell> chown-R root.

Shell> chown-R mysql data

Shell> bin/mysqld_safe-user = mysql &

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.