MySQL for RedHat Linux (source installation, installation package)

Source: Internet
Author: User
Tags check character localhost mysql

  1. Preparatory work
    In xx go all download install package Mysql.zip
    Put the corresponding package in the/OPT directory to decompress Mysql.zip
  2. Detects if the system has MySQL installed
    1. Execution #rpm-qa | Grep-i MySQL
    If it appears:
    [[email protected] mysql]# rpm-qa|grep-i Mysql

    [Email protected] mysql]#
    MySQL is not installed, do a third step directly, otherwise install MySQL, perform the 2nd step, uninstall MySQL

    2, uninstall MySQL, please see the address in detail: http://www.iitshare.com/centeros-6-3-64-bit-uninstall-mysql5-5-25.html

    If the system comes with MySQL

    Judge system comes with MySQL, execute #rpm-qa | Grep-i MySQL
    If it appears (similar):

    [[email protected] mysql]# rpm-qa|grep-i Mysql

    Mysql-libs-5.1.66-2.el6_3.x86_64

    Then execute: [[email protected] mysql]# Rpm–ev --nodeps mysql-libs-5.1.66-2.el6_3.x86_64 Uninstall Mysql

  3. Install MySQL
    1. Go to the installation package directory

      [Email protected] mysql]# cd/opt/mysql/

      [[email protected] mysql]# ls

      [[email protected] Mysql] #rpm

    2. Check that the native Linux is installed make,bison,cmake,gcc-c++,ncurses, if not installed, first install the above package, the installation method is as follows:

      [Email protected] mysql]# RPM–IVH libgcc-4.4.7-3.el6.x86_64.rpm

      [Email protected] mysql]# RPM–IVH libstdc++-devel-4.4.7-3.el6.x86_64.rpm

      [Email protected] mysql]# RPM–IVH gcc-4.4.7-3.el6.x86_64.rpm

      [Email protected] mysql]# RPM–IVH gcc-c++-4.4.7-3.el6.x86_64.rpm

      [Email protected] mysql]# RPM–IVH bison-2.4.1-5.el6.x86_64.rpm

      [Email protected] mysql]# RPM–IVH ncurses-devel-5.7-3.20090208.el6.x86_64.rpm

      ?

      Note: The general system will be installed by default with make

    3. Installing CMake

      [[email protected] Mysql] #tar –zxv–f cmake-2.8.9.tar.gz

      [[email protected] Mysql] #cd cmake-2.8.9

      [Email protected] mysql]#./configure

      [[email protected] Mysql] #make

      [[email protected] Mysql] #make Install

    4. Create a MySQL installation directory and database storage directory
      [[email protected] Mysql] #mkdir-P/usr/local/mysql

      [[email protected] Mysql] #mkdir-P/usr/local/mysql/data

    5. Create MySQL users and user groups
      [[email protected] mysql]# Groupadd Mysql

      [[email protected] mysql]# useradd-r-g MySQL MySQL

    6. Install MySQL

      [[email protected] Mysql] #tar –zxv–f mysql-5.6.16.tar.gz

      [[email protected] Mysql] #cd mysql-5.6.16

      [Email protected] mysql]# CMake. -dcmake_install_prefix=/usr/local/mysql/-dmysql_datadir=/usr/local/mysql/data-dwith_innobase_storage_engine=1- Dmysql_tcp_port=3306-dmysql_unix_addr=/usr/local/mysql/data/mysql.sock-dmysql_user=mysql-dwith_debug=0- Ddefault_charset=utf8-ddefault_collation=utf8_general_ci

      Note: This command is one line

      [[email protected] Mysql] #make

      [[email protected] Mysql] #make Install

      ?

      Parameter description:

      -dcmake_install_prefix=/usr/local/mysql//installation directory

      -dinstall_datadir=/usr/local/mysql/data//Database storage directory

      -ddefault_charset=utf8//using UTF8 characters

      -DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character

      -dextra_charsets=all//Install all extended character sets

      -denabled_local_infile=1//Allow import of data from local

      ?

      Precautions:

      When you recompile, you need to clear the old object file and cache information. Compile process can be intuitive to see the success of the compilation did not

      # Make Clean

      # rm-f CMakeCache.txt

      # RM-RF/ETC/MY.CNF

      ?

      Configuration

      [Email protected] mysql]# Cd/usr/local/mysql

      [Email protected] mysql]# chown-r root:mysql.

      [Email protected] mysql]# chown-r mysql:mysql data

      [[email protected] MySQL] #cp/opt/mysql/my.cnf/etc/my.cnf

      [Email protected] mysql]# Cd/usr/local/mysql

      [Email protected] mysql]# scripts/mysql_install_db--user=mysql

      Setting environment variables

      [Email protected] mysql]# Vi/root/.bash_profile

      In path= $PATH: $HOME/bin add parameters as:

      Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib

      Save changes

      [Email protected] mysql]# Source/root/.bash_profile

      ?

      Manually start MySQL

      [email protected] localhost ~]# cd/usr/local/mysql

      [[email protected] localhost mysql]#./bin/mysqld_safe--user=mysql &//start MySQL, but not stop

      The boot log is written under this file:/usr/local/mysql/data/localhost.err

      Turn off MySQL service

      [[email protected] localhost mysql]# mysqladmin-u root-p shutdown//Here the root user of MySQL has not configured the password, so it is null. If you need to enter a password, just click Enter.

      Another simple way to start MySQL (MySQL has been added to the system service)

      [[email protected] localhost ~]# service mysql.server start

      [[email protected] localhost ~]# service mysql.server stop

      [email protected] localhost ~]# service mysql.server restart

      If the above command appears: Mysql.server Unrecognized service

      ?

      It is possible that MySQL has not been added to the system service, which is added in another way:

      [[email protected] localhost mysql]# CP support-files/mysql.server/etc/init.d/mysql//Add MySQL startup service to system service

      Note: The main is to copy Mysql.server to/etc/init.d, named MySQL. In some systems, Mysql.server is in/usr/local/mysql/share/mysql/mysql.server, and in this system, mysql.server in cd/usr/local/mysql/ The Support-files/mysql.server.

      ?

      Then use #service MySQL start to start MySQL.

    7. detect mysql 3306 Whether the port is open: [[[email protected] mysql]# netstat–nat

      If mysql 3306 Span style= "font-family: Song body; Background-color:white "> port open

      Active Internet connections (servers and established)

      Proto recv-q send-q Local address Foreign address State

      TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

      If no 3306 port is started, the MySQL service does not start

      Start MySQL service: Service mysqld start or service MySQL start

      In detection mysql 3306 Whether the port is open: [[email protected] mysql]# netstat–nat

    8. Modify MySQL Password
      Optional step: Set Root password:

      /usr/local/mysql/bin/mysqladmin-u root password ' new-password '

      /usr/local/mysql/bin/mysqladmin-u root-h localhost.localdomain password ' new-password '

      This step requires the database to be started before it can be successfully executed)

      ?

      The following is another way to modify the password for the root user of MySQL and to open a remote connection

      [[email protected] rhel5~]# mysql-u root MySQL

      Mysql>use MySQL;

      Mysql>desc user;

      Mysql> GRANT All privileges on * * to [email protected] '% ' identified by ' root '; The ability to add remote connections for root.

      Mysql>update user Set Password = Password (' xxxxxx ') where user= ' root ';

      Mysql>select Host,user,password from User where user= ' root ';

      Mysql>flush privileges;

      Mysql>exit

      ?

      Re-login: Mysql-u root-p

      ?

      If remote connections are not yet in progress, turn off the firewall

      [[email protected] rhel5~]#/etc/rc.d/init.d/iptables stop

      Copy Code

      Note: If you cannot connect remotely, error MySQL error number 1130, then add the following statement to try:

      ?

      Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' ****** ' with GRANT OPTION;

      ?

      ?

    9. PS aux |grep mysq* See the process about MySQL

MySQL for RedHat Linux (source installation, installation package)

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.