Linux installation mysql--source installation

Source: Internet
Author: User
Tags check character

1. Assume that there are already mysql-5.5.10.tar.gz and cmake-2.8.4.tar.gz two source files

(1) Install CMake First (mysql5.5 is compiled by CMake later)

[[email protected] rhel5 Local] #Tar-zxv-f cmake-2.8.4.tar.gz
[[email protected] rhel5 Local] #CD cmake-2.8.4
[[email protected] rhel5 cmake-2.8.4] #./configure
[[email protected] rhel5 cmake-2.8.4] #make
[[email protected] rhel5 cmake-2.8.4] # makeinstall


(2) Create a MySQL installation directory and database storage directory

[[email protected] rhel5~] #Mkdir-p/usr/local/mysql                 
[[email protected] rhel5~] #Mkdir-p/usr/local/mysql/data //Storage database

(3) Create MySQL users and user groups

[[email protected] Rhel5~]groupadd MySQL
[[Email protected] rhel5~]useradd-r-g MySQL MySQL

(4) Installing MySQL

 [[email protected] rhel5 local]#tar-zxv-f Mysql-5.5.10.tar.gz 
[[email protected] Rhel5 Local] #CD mysql-5.5.10
[ [email protected] rhel5 mysql-5.5.10]#cmake. Span style= "color: #008000;" >
-dcmake_install_prefix=/usr/local/mysql
-dmysql_datadir=/usr/local/mysql/data
-DDEFAULT_CHARSET= UTF8
-ddefault_collation=utf8_general_ci

-denabled_local_infile=1
[[email protected] rhel5 mysql-5.5.10] #make
[[email protected] rhel5 mysql-5.5.10] # makeinstall

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.

# Make Clean

# rm-f CMakeCache.txt

# RM-RF/ETC/MY.CNF

2. Configuration

(1) Set directory permissions

[[email protected] rhel5~] # Cd/usr/local/mysql

[[email protected] rhel5 MySQL] # Chown-r root:mysql.//Set the owner owner of all files in the current directory to root, the group is MySQL

[[email protected] rhel5 MySQL] # chown-r mysql:mysql data

(2)

[[email protected] rhel5 MySQL] # CP support-files/my-medium.cnf/etc/my.cnf//Add MySQL startup service to system service 



(3) Create a table for the system database

[[email protected] rhel5 MySQL] # Cd/usr/local/mysql
[[email protected] rhel5 MySQL] # scripts/mysql_install_db--user=mysql

(4) Setting environment variables

[[email protected] rhel5~] # Vi/root/.bash_profile

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

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

[[email protected] rhel5~] #Source/root/.bash_profile

(5) manually start MySQL

[[email protected] rhel5~] # Cd/usr/local/mysql

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

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

Turn off MySQL service

[[email protected] rhel5 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.

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

[[email protected] rhel5~] # Service mysql.server start  
[[email protected] rhel5~] # Service Mysql.server Stop
[[email protected] rhel5~] # 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] RHEL5 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/usr/local/mysql/ The Support-files/mysql.server.

Then use #service MySQL start to start MySQL.


(7) Change the password of the root user of MySQL and open the remote connection

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

Mysql>use MySQL;
Mysql>desc user;
Mysql> GRANT All privileges on * * to [email protected]"%"root "; The ability to add remote connections for root.
Mysql>update user Set Password = Password (' xxxxxx ') 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

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;

Linux installation mysql--source 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.