Install MySQL 5.1 correctly in Linux

Source: Internet
Author: User

The following article describes how to install MySQL 5.1 correctly in Linux. First, we download the MySQL database free of installation version, that is, the binary version of the software is free of charge ), the following is the description of the specific content of the article. I hope you will gain some benefits after browsing it.

1. Download MySQL installation-free/binary software without compilation)

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

2. Create a MySQL group, create a MySQL user, and add the user to a different version of Unix in the mysql group. The groupadd and useradd syntaxes may be slightly different .)

 
 
  1. #groupadd mysql  
  2. #useradd -g mysql mysql 

3. Enter the/usr/local directory, decompress and install MySQL 5.1, and create a soft link named mysql in this directory.

 
 
  1. #cd /usr/local  
  2. #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:

 
 
  1. #> tar zxvf /path/to/mysql-VERSION-OS.tar.gz)  
  2. #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.

 
 
  1. #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 the access permissions for mysql and root accounts.

 
 
  1. #cd mysql  
  2. #chown -R mysql .  
  3. #chgrp -R mysql .  
  4. #scripts/mysql_install_db –user=mysql 
  5. #chown -R root .  
  6. #chown -R mysql data 

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

6. Run MySQL

 
 
  1. #bin/mysqld_safe –user=mysql & 

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

 
 
  1. [1] 42264  
  2. # 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 password for installing MySQL 5.1 is blank by default. You need to change the password for security purposes.

 
 
  1. #/usr/local/mysql/bin/mysqladmin -uroot password yourpassword 

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

 
 
  1. #cp support-files/mysql.server /etc/rc.d/init.d/mysqld  
  2. #chmod 700 /etc/init.d/mysqld  
  3. #chkconfig –add mysqld  
  4. #chkconfig –level 345 mysqld on 

9. Start the mysqld service

 
 
  1. #service mysqld start 

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

 
 
  1. #netstat -atln 

Basic commands for installing MySQL 5.1 for the free/binary version:
 

 
 
  1. shell> groupadd mysql  
  2. shell> useradd -g mysql mysql  
  3. shell> cd /usr/local  
  4. shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -  
  5. shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql  
  6. shell> cd mysql  
  7. shell> chown -R mysql .  
  8. shell> chgrp -R mysql .  
  9. shell> scripts/mysql_install_db –user=mysql 
  10. shell> chown -R root .  
  11. shell> chown -R mysql data  
  12. shell> bin/mysqld_safe –user=mysql & 

The above content is an introduction to installing MySQL 5.1 in Linux. I hope you will have some gains.


Related Article

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.