Create a MySQL user and a MySQL user group
Groupadd MySQL
Useradd-G MySQL
Install MySQL using the source package
1.download the mysqlinstallation package (.tar.gz) from mysql's official website)
Http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51a.tar.gz/from/pick
2.set mysql-5.0.51a.tar.gz to the directory/home/mahaibo after download.
Install MySql in the directory:/home/mahaibo/install/MySQL
Directory of the mysql. Sock file called by MySQL:/home/mahaibo/install/sock
Directory of the my. CNF configuration file called by MySQL:/home/mahaibo/install/Conf
MySQL data directory:/home/mahaibo/install/Data
3.decompress mysql-5.0.51a.tar.gz
- Tar-zxvf mysql-5.0.51a.tar.gz
tar -zxvf mysql-5.0.51a.tar.gz
4. Configure preparations before Compilation:
- . /Configure -- prefix =/home/mahaibo/install/MySQL -- localstatedir =/home/mahaibo/install/data -- With-Unix-socket-Path =/home/mahaibo/install/ sock
./configure --prefix=/home/mahaibo/install/mysql --localstatedir=/home/mahaibo/install/data --with-unix-socket-path=/home/mahaibo/install/sock
-- Localstatedir data directory Parameters
-- With-Unix-socket-path MySQL. Sock directory Parameters
Note: You can use./configure -- help to view the specific parameters of./configure. Except for -- prefix, parameters like -- localstatedir -- With-Unix-socket-path can be configured in my. CNF. If my. CNF is not configured. the/configure parameter prevails. CNF is configured, so my. the value in CNF will overwrite. /configure parameter value
If neither my. CNF nor./configure is configured, the default value is used.
The default value of the data directory is: If MySQL is installed through the source package, the default location of the MySQL data directory is/usr/local/var. If MySQL is installed through the Binary Package, it is/usr/local/MySQL/data. If it is installed through the RPM file, it is/var/lib/MySQL
Default mysql. Sock Directory:/tmp/MySQL. Sock
My. CNF default directory:/etc/My. CNF
5. Compile and install
- Make
- Make install
makemake install
6. generate basic Mysql Data Information and basic table structure in the data directory.
- ./Scripts/mysql_install_db -- user = MySQL -- datadir =/home/mahaibo/install/Data
./scripts/mysql_install_db --user=mysql --datadir=/home/mahaibo/install/data
Set the data directory to mysql users and user groups.
- Chown-r MYSQL: MySQL DATA
chown -R mysql:mysql data
After execution, you can generate two directories under the/home/mahaibo/install/data directory, MySQL and test.
7.
- Mkdir Conf
mkdir conf
- Mkdir sock
mkdir sock
Modify the sock directory permission so that mysql users can write
- Chmod 777 sock
chmod 777 sock
8. Copy my. CNF
- CP/home/mahaibo/mysql-5.0.51a/support-files/my-medium.cnf/home/mahaibo/install/CONF/
cp /home/mahaibo/mysql-5.0.51a/support-files/my-medium.cnf /home/mahaibo/install/conf/
Change name: MV my-medium.cnf my. CNF
Modify: in the [client] and [mysqld] sections, add the following parameters: Socket =/home/mahaibo/install/sock/MySQL. Sock.
9. Start MYSQL:
- ./Mysqld_safe -- defaults-file =/home/mahaibo/install/CONF/My. CNF &
./mysqld_safe --defaults-file=/home/mahaibo/install/conf/my.cnf &
You can view the parameters through./mysqld_safe -- help.
If the -- defaults-file parameter is not added, the default directory of my. CNF is used by default to locate/etc/My. CNF.
You can view it through netstat-lnt. If Port 3306 exists, it indicates that the startup is successful.
10. Log on to MySQL:
- Mysql-uroot-S/home/mahaibo/install/sock/MySQL. Sock
mysql -uroot -S/home/mahaibo/install/sock/mysql.sock
At the beginning of MySQL, a root user is created by default and the password is blank. If the-S parameter is not added, find mysql. sock in the default directory, that is,/tmp/MySQL. Sock.
11. Close MYSQL:
- Mysqladmin shutdown-S/home/mahaibo/install/sock/MySQL. Sock
mysqladmin shutdown -S/home/mahaibo/install/sock/mysql.sock
If the-S parameter is not added, find mysql. sock in the default directory, that is,/tmp/MySQL. Sock.
Reference: http://www.javaeye.com/topic/161165