MySQL binary installation

Source: Internet
Author: User
Tags reserved



Binary installation is actually already compiled MySQL, do a compressed package, download down, unzip, simple configuration, you can use, ' install ' fast, often used for rapid deployment of MySQL.


To add a MySQL user:


[[email protected] ~]# groupadd mysql[[email protected] ~]# useradd-s/sbin/nologin-g mysql-m MySQL

-s/sbin/nologin indicates that the user is prevented from logging into the system for increased security

-G MySQL Specifies that the MySQL user belongs to the MySQL group

-M indicates that no user home directory is created (no need to create it here)



Check the MySQL users and groups you just created:


[[email protected] ~]# tail-1/etc/passwdmysql:x:501:501::/home/mysql:/sbin/nologin[[email protected] ~]# ID mysqluid= 501 (MySQL) gid=501 (MySQL) groups=501 (MySQL)





To get the MySQL package:


On the MySQL official website select Linux-generic The package that this article uses is mysql-5.5.49-linux2.6-x86_64.tar.gz

Platform is centos6.4

Http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz

5.5 version of MySQL, empty password, can be directly logged in


[[email protected] ~]# wget http://dev.mysql.com/get/downloads/mysql-5.5/ mysql-5.5.49-linux2.6-x86_64.tar.gz                 #   get MySQL software compression pack [[email protected] ~]# tar xf  mysql-5.5.49-linux2.6-x86_64.tar.gz        #  Decompression [[email  protected]  ~]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49#     move to the specified installation directory, the directory indicates the version of MySQL (  binary installation can customize the installation directory  ) [[Email protected]  ~]# ln  -s /application/mysql-5.5.49/  /application/mysql#     Create a soft link  [[ Email protected] ~]# cd /application/mysql[[email protected] mysql]# lsbin       data  include          lib  mysql-test  scripts  sql-benchcopying  docs  install-binary  man  readme       share    support-files





Initialize the MySQL configuration file my.cnf:

There are various configuration samples for my.cnf under Support-file, and the configuration file is selected according to the situation.

[Email protected] mysql]#/BIN/CP support-files/my-small.cnf/etc/my.cnf



Initialize the MySQL database file:

[[email protected] mysql]# mkdir -p / application/mysql/data  #  build MySQL data file directory [[Email protected] mysql]# chown -r  mysql.mysql /application/mysql/    #   authorizing MySQL users to manage the installation directory for MySQL [email  protected] mysql]#  /application/mysql/scripts/mysql_install_db \  #  Initialize MySQL database file > --basedir=/application/mysql \        #   Specify MySQL directory > --datadir=/application/mysql/data \   #  specify MySQL data file directory >  --user=mysql                           #  specified user #   initialization will have 2  ok &NBSP, if there is a error  error, it is necessary to resolve, and then initialize the 

Note: Some package mysql_install_db are not in the scripts directory and may be in the bin directory or other directory





Configure and start the MySQL database:

[[email protected] mysql]# cp support-files/mysql.server/etc/init.d/mysqld # Copy MySQL boot script to mysql command path [[email protected] mysql]# chmod +x/etc/init.d/mysqld # Add Execute permission [[email protected] mysql]# sed-i ' S#/usr/local/mysql#/application/mysql #g '/application/mysql/bin/mysqld_safe/etc/init.d/mysqld# mysql binary default installation path is/usr/local/mysql, the startup script is/usr/local/ MySQL paths need to be replaced by [[email protected] mysql]#/etc/init.d/mysqld startstarting MySQL ... success!




Set MySQL boot to start automatically:

[[email protected] mysql]# chkconfig--add mysqld[[email protected] mysql]# chkconfig mysqld on[[email protected] mysql]# Chkconfig--list mysqldmysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off




Log in to MySQL database:

[Email protected] ~]#/application/mysql/bin/mysqlwelcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 2Server version:5.5.49 mysql Community Server (GPL) Copyright (c), Oracle and /or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>



This startup is too cumbersome to configure the global use path of the MySQL command :

[[email protected] mysql]# echo  ' Export path=/application/mysql/bin: $PATH '  > > /etc/profile #   append   ' export path=/application/mysql/bin: $PATH ' to  /etc/ profile[[email protected] mysql]# source /etc/profile  #   make the Append content effective  #   above uses to define MySQL global path, implement MySQL command on any path  [[email protected] ~]# mysql    #  Direct access to Mysqlwelcome to the mysql monitor.  commands end  with ; or \g.your mysql connection id is 3server version:  5.5.49 MySQL Community Server  (GPL) copyright  (c)  2000, 2016,  Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be traDemarks of their respectiveowners. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  STATEMENT.MYSQL>&NBSP, ..... [[email protected] ~]# mysql -uroot -p     #  can also log in like this, No need to use a password



To set the root password for MySQL:

[[email protected] mysql]# mysqladmin -u root password  ' Redhat ' [[Email  protected] mysql]# mysqlERROR 1045  (28000): access denied for  user  ' root ' @ ' localhost '   (using password: no) [[email protected] mysql]#  mysql -uroot -penter password: welcome to the mysql monitor.   Commands end with ; or \g.Your MySQL connection id is  6server version: 5.5.49 mysql community server  (GPL) Copyright  (c)  2000 ,  2016, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. type  ' \c '  to clear the current input statement.mysql >




Compared to the official website of the Rpm/yum installation, the binary installation can change the installation path, but in essence just put the compiled good come over, if you have any special needs, and can not meet. If you have any special needs, you should use the source code to compile the installation.






This article is from the "11417860" blog, please be sure to keep this source http://11427860.blog.51cto.com/11417860/1770537

MySQL binary installation

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.