1. First install the CMake
- # wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
- # tar zxvf cmake-2.8. 4.tar.gz
- # CD cmake-2.8. 4
- #./configure
- # make
- # make Install
2. Pre-installation system settings
Build MySQL installation directory and data storage directory
- # Mkdir/opt/mysql
- # Mkdir/data/mysql/data
Create users and user groups
- # Groupadd MySQL
- # useradd-g MySQL MySQL
Assigning permissions to the data store directory
- # chown Mysql:mysql-r/data/mysql/data
3. Compiling MySQL with CMake
- # tar zxvf mysql-5.5. 13.tar.gz
- # 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
- 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
- # 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
- # RM-FR CMakeCache.txt
CMake finished.
- # make
- # make Install
To this MySQL installation is complete
4. Configure and initialize the database
Create a MY.CNF configuration file
- # Mkdir/opt/mysql/log
- # MKDIR/OPT/MYSQL/ETC
- # 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
- # chmod 755 scripts/mysql_install_db
- # scripts/mysql_install_db--user=mysql--basedir=/opt/mysql/--datadir=/data/mysql/data/
Create a shell script that manages the MySQL database
- # MKDIR/OPT/MYSQL/INIT.D
- # CP Support-files/mysql.server/opt/mysql/init.d/mysql
To give the shell script executable permissions:
- # chmod +x/opt/mysql/init.d/mysql
Start MySQL:
- #/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
- Rm-fr/data/mysql/data
- Mkdir/data/mysql/data
Re-create MySQL basic data to execute in MySQL directory
- chmod 755 scripts/mysql_install_db
- scripts/mysql_install_db--user=mysql--basedir=/opt/mysql/--datadir=/data/mysql/data/
- Authorized
- chmod +x/opt/mysql/init.d/mysql
- Start
- /opt/mysql/init.d/mysql start
Error:
- /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
- # chmod U+x/opt/mysql/data
If you want to specify a custom data storage path.
Need to modify service startup file
- # Vim/opt/mysql/init.d/mysql
Specify one of the
- Datadir=/data/mysql/data
Then authorize
- # 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):
- #/opt/mysql/bin/mysql-u Root-p-s/tmp/mysql.sock
Set the initial password for the root account
- #/opt/mysql/bin/mysqladmin-u root password ' New-password '
Set MySQL boot up
- Cp/opt/mysql/init.d/mysql/etc/init.d/mysql
- chmod 755/etc/init.d/mysql
- Chkconfig MySQL on
- Restart takes effect
- Reboot
Enter the following SQL statement to create a user with root privileges (admin) and password (12345678):
- GRANT all privileges on * * to ' admin ' @' localhost ' identified by ' 12345678 ';
- GRANT all privileges on * * to ' admin ' @' 127.0.0.1 ' identified by ' 12345678 ';
Access to all IP settings for root user
- Grant all privileges on * * to [email protected]'% ' identified by ' password ';
You can also specify IP
- Grant all privileges on * * to [e-mail protected]' 192.168.1.125 ' identified by ' password ';
Specify IP Segment
- Grant all privileges on * * to [e-mail protected]' 192.168.1.% ' identified by ' password ';
Remove the empty password account for the native anonymous connection
- /opt/mysql/bin/mysql-uroot-p' New-password '
- Mysql>use MySQL; //select system database MySQL
- Mysql>select Host,user,password from User; //View all users
- Mysql>delete from user where password="";
- Mysql>flush privileges;
- Mysql>select Host,user,password from User; //Confirm that a user with a blank password has been completely deleted
- mysql>exit;
Source code compilation Install MySQL