Install and deploy MySQL5.1.40forLinux

Source: Internet
Author: User
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 mysql

1. Download MySQL installation-free/binary software (do not compile) File Format: MYSQL-VERSION-OS.tar.gz2, create MySQL groups, create MySQL users and add to mysql

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

#> 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 Directory Access Permissions, use mysql_install_db to create a MySQL authorization table for initialization, and set 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-u root password yourpassword

8. Go to the mysql page:

Bin/mysql-u root-p

Prompt to enter the password, and then show databases to show that there are some databases, and then use the use mysql database;

9. 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

10. Start the mysqld service

# Service mysqld start

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

# Netstat-atln

12. log on to mysql

Bin/mysql-u root-p

Show databases

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 &

13. Start and Stop the service:

Support-files/mysql. server start

Support-files/mysql. server stop

14. Test after installation:

After the database is installed, the windows client cannot be connected. The general cause is that linux has a firewall and the client machine does not have access permissions. The modification is as follows:

1). chkconfig iptables on is enabled.

Chkconfig iptables off

The above takes effect permanently after restart

/Etc/init. d/iptables stop temporarily takes effect and becomes invalid after restart

2) mysql> use mysql;

Mysql> update user set host = '%' where user = 'root ';

Mysql> flush privileges;

Mysql> select 'host', 'user' from user where user = 'root ';

Mysql> quit

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.