Linux environment MySQL5.1 installation steps: 1, download MySQL free installation version/binary version of the software (do not compile) file format: MYSQL-VERSION-OS.tar.gz2, create a MySQL Group, create a MySQL User and add it to the mysql group (in Unix of different versions, the groupadd and useradd syntaxes may be slightly
Install MySQL5.1 in Linux:
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 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 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 &