Install MySQL on Linux

Source: Internet
Author: User

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

  1. Tar-zxvf mysql-5.0.51a.tar.gz
tar -zxvf mysql-5.0.51a.tar.gz 

4. Configure preparations before Compilation:

  1. . /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

  1. Make
  2. Make install
makemake install

6. generate basic Mysql Data Information and basic table structure in the data directory.

  1. ./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.

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

  1. Mkdir Conf
mkdir conf
  1. Mkdir sock
mkdir sock

Modify the sock directory permission so that mysql users can write

  1. Chmod 777 sock
chmod 777 sock

8. Copy my. CNF

  1. 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:

  1. ./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:

  1. 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:

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

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.