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 .)
- #groupadd mysql
- #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.
- #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 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.
- #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 less .)
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 password for installing MySQL 5.1 is blank by default. You need to change the password for security purposes.
- #/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
Basic commands for installing MySQL 5.1 for the free/binary version:
- shell> groupadd mysql
- shell> useradd -g mysql 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 &
The above content is an introduction to installing MySQL 5.1 in Linux. I hope you will have some gains.