Source code compilation Install MySQL

Source: Internet
Author: User
Tags chmod

1. First install the CMake

    1. # wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
    2. # tar zxvf cmake-2.8. 4.tar.gz
    3. # CD cmake-2.8. 4
    4. #./configure
    5. # make
    6. # make Install



2. Pre-installation system settings

Build MySQL installation directory and data storage directory

    1. # Mkdir/opt/mysql
    2. # Mkdir/data/mysql/data



Create users and user groups

    1. # Groupadd MySQL
    2. # useradd-g MySQL MySQL



Assigning permissions to the data store directory

    1. # chown Mysql:mysql-r/data/mysql/data



3. Compiling MySQL with CMake

    1. # tar zxvf mysql-5.5. 13.tar.gz
    2. # CD mysql-5.5. -



Compile parameters:  
Note that the installation path and data path are the previously established  

cmake-dcmake_install_prefix=/opt/mysql \ 
-dsysconfdir=/opt/mysql/etc \ 
-dmysql_datadir=/data/mysql/data \ 
-DMYSQL_TCP_PORT= 3306 \ 
-dmysql_unix_addr=/tmp/mysqld.sock \ 
-dmysql_user=mysql \ 
-dextra_charsets=all \  
-dwith_readline=1 \ 
-dwith_ssl=system \ 
-dwith_embedded_server=1 \ 
-DENABLED _local_infile=1 \ 
-dwith_innobase_storage_engine=1 \ 
-dwithout_partition_storage_engine=1  

    1. Cmake-dcmake_install_prefix=/opt/mysql-dsysconfdir=/opt/mysql/etc-dmysql_datadir=/data/mysql/data-dmysql_tcp_ port=3306-dmysql_unix_addr=/tmp/mysqld.sock-dmysql_user=mysql-dextra_charsets=all-dwith_readline=1- dwith_ssl=system-dwith_embedded_server=1-denabled_local_infile=1-dwith_innobase_storage_engine=1- dwithout_partition_storage_engine=1



If you encounter an error message:
Curses Library not found. Please install the appropriate package.

Install with Yum

    1. # yum Install Ncurses-devel



http://www.ui3net.com/basic-installation-of-mysql-from-source/

If the first compilation fails or there is a problem
Clean up the MySQL directory under the CMakeCache.txt recompile

    1. # RM-FR CMakeCache.txt



CMake finished.

    1. # make
    2. # make Install



To this MySQL installation is complete

4. Configure and initialize the database

Create a MY.CNF configuration file

    1. # Mkdir/opt/mysql/log
    2. # MKDIR/OPT/MYSQL/ETC
    3. # CP SUPPORT-FILES/MY-MEDIUM.CNF/OPT/MYSQL/ETC/MY.CNF



Initializing the database
Need to assign scripts/mysql_install_db file execution permissions before execution

    1. # chmod 755 scripts/mysql_install_db
    2. # scripts/mysql_install_db--user=mysql--basedir=/opt/mysql/--datadir=/data/mysql/data/



Create a shell script that manages the MySQL database

    1. # MKDIR/OPT/MYSQL/INIT.D
    2. # CP Support-files/mysql.server/opt/mysql/init.d/mysql



To give the shell script executable permissions:

    1. # chmod +x/opt/mysql/init.d/mysql




Start MySQL:

    1. #/opt/mysql/init.d/mysql Start



Error occurred:
Starting MySQL ..... error! The server quit without updating PID file.

Go to the Mysql/data directory to view the corresponding. err file
Where there is a description of the error
One case is due to incomplete data creation or authorization issues
Solution:
Rebuild Data Catalog

    1. Rm-fr/data/mysql/data
    2. Mkdir/data/mysql/data


Re-create MySQL basic data to execute in MySQL directory

    1. chmod 755 scripts/mysql_install_db
    2. scripts/mysql_install_db--user=mysql--basedir=/opt/mysql/--datadir=/data/mysql/data/
    3. Authorized
    4. chmod +x/opt/mysql/init.d/mysql
    5. Start
    6. /opt/mysql/init.d/mysql start




Error:

    1. /mysql-bin.index ' not Found (errcode:


Issue with data file authorization.
See the cause of the error in the wrong log file Pop1.err
A bad MySQL data path, such as/opt/mysql/data, is typically indicated
The reason for the error is that the directory that was authorized before the citation did not actually point to the MySQL data path.
MySQL uses this error path, so there is no authorization.
If you use this error path. Direct authorization can

    1. # chmod U+x/opt/mysql/data



If you want to specify a custom data storage path.
Need to modify service startup file

    1. # Vim/opt/mysql/init.d/mysql



Specify one of the

    1. Datadir=/data/mysql/data



Then authorize

    1. # chmod U+x/data/mysql/data



5. Modify MySQL default password, etc.

Log in to manage the MySQL server via the command line (enter directly when prompted for the password):

    1. #/opt/mysql/bin/mysql-u Root-p-s/tmp/mysql.sock



Set the initial password for the root account

    1. #/opt/mysql/bin/mysqladmin-u root password ' New-password '



Set MySQL boot up

    1. Cp/opt/mysql/init.d/mysql/etc/init.d/mysql
    2. chmod 755/etc/init.d/mysql
    3. Chkconfig MySQL on
    4. Restart takes effect
    5. Reboot



Enter the following SQL statement to create a user with root privileges (admin) and password (12345678):

    1. GRANT all privileges on * * to ' admin ' @' localhost ' identified by ' 12345678 ';
    2. GRANT all privileges on * * to ' admin ' @' 127.0.0.1 ' identified by ' 12345678 ';


Access to all IP settings for root user

    1. Grant all privileges on * * to [email protected]'% ' identified by ' password ';


You can also specify IP

    1. Grant all privileges on * * to [e-mail protected]' 192.168.1.125 ' identified by ' password ';


Specify IP Segment

    1. Grant all privileges on * * to [e-mail protected]' 192.168.1.% ' identified by ' password ';



Remove the empty password account for the native anonymous connection

        1. /opt/mysql/bin/mysql-uroot-p' New-password '
        2. Mysql>use MySQL; //select system database MySQL
        3. Mysql>select Host,user,password from User; //View all users
        4. Mysql>delete from user where password="";
        5. Mysql>flush privileges;
        6. Mysql>select Host,user,password from User; //Confirm that a user with a blank password has been completely deleted
        7. mysql>exit;

Source code compilation Install MySQL

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.