After reading a few documents, have not written completely. A little tidying up, re-step to compile and install MySQL on the centos7.
The installation steps are as follows:
1. Install the compilation environment
# yum-y Install gcc-gcc-c++ ncurses-devel per # yum Install CMake |
2. build mysql directory and account number, and directory properties
# mkdir-p/data/mydata # mkdir-p/usr/local/mysql # useradd-d/data/mydata-s/sbin/nologin-g MySQL MySQL # CD data/mydata/ # Chown-r Mysql:mysql. # cd/usr/local/mysql/ # Chown-r Mysql:mysql. |
3. Download copy to System
# CD # ls Anaconda-ks.cfg mysql-5.6.22.tar.gz |
4. Unzip the MySQL source package
# TAR-ZXVF MYSQL-5.6.22.TAR.G |
5. compiling mysql source package
Description: from mysql5.5 ,mysql source installation started using CMake , set the source code compilation configuration script.
-dcmake_install_prefix=dir_name |
setting up the MySQL installation directory |
-dmysql_unix_addr=file_name |
set the listener socket path, which must be an absolute pathname. Default is /tmp/mysql.sock |
-ddefault_charset=charset_name |
Sets the character set of the server. by default, MySQL uses the latin1 (CP1252 Western European) character set. The Cmake/character_setsnanake file contains a list of allowed character set names. |
-ddefault_collation=collation_name |
Sets the collation of the server. |
-dwith_innobase_storage_engine=1 -dwith_archive_ Storage_engine=1 -dwith_blackhole_storage_engine=1 -dwith_perfschema_storage_engine=1 |
storage engine options: myisam merge Memory engine is compiled to the server by default and does not need to be explicitly installed. static compilation of a storage engine to the server, using -dwith_engine_storage_ engine= 1 ARCHIVE, Blackhole, EXAMPLE, Federated, Innobase (InnoDB), partition (partitioning support), Perfschema (performance Schema) |
-dmysql_datadir=dir_name |
set the MySQL database file directory |
-dmysql_tcp_port=port_num |
set the MySQL server listening port, default to 3306 |
-denable_downloads=bool |
whether you want to download the optional files. For example, if you enable this option (set to 1),cmake will download the test suite that Google uses to run unit tests. |
# CD mysql-5.6.22 # Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=mysql.mysql-ddefault_charset=gbk-ddefault_ Collation=gbk_chinese_ci-dwith_innobase_storage_engine=1-dwit h_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dmysql_datadir=/data/mydata-dmysql_tcp_port=3306- Denable_downloads=1 [[email protected] mysql-5.6.22]# make [[email protected] mysql-5.6.22]# make install |
6. Initialize mysql database
# CD scripts/ # ls mysql_install_db #./mysql_install_db--user=mysql--datadir=/data/mydata FATAL Error:please Install the following Perl modules before executing./MYSQL_INSTALL_DB: Data::D umper error during initialization, need to install Perl-module-install.noarch # yum Install-y Perl-module-install.noarch # scripts/mysql_install_db--user=mysql--datadir=/data/mydata To start mysqld at boot time with to copy Support-files/mysql.server to the right place for your system REMEMBER to SET A PASSWORD for the MySQL root USER! To does so, start the server, then issue the following commands: ./bin/mysqladmin-u root password ' new-password ' ./bin/mysqladmin-u root-h localhost.localdomain password ' new-password ' Alternatively you can run: ./bin/mysql_secure_installation Which would also give you the option of removing the test Databases and anonymous user created by default. This is Strongly recommended for production servers. See the Manual for more instructions. You can start the MySQL daemon with: Cd. ;./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl CD mysql-test; Perl mysql-test-run.pl Problems at http://bugs.mysql.com/ The latest information about MySQL was available on the Web at Http://www.mysql.com Support for MySQL by buying support/licenses at http://shop.mysql.com New Default Config file was created as./my.cnf and Would be used by default by the server when you start it. You could edit this file to the Change server settings |
7. copy mysql service and startup files
# CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF # Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld |
8. Open mysqld service
[[Email protected] ~]# service mysqld start Starting MySQL. success! |
9. Add to chkconfig
[Email protected] ~]# Chkconfig [Email protected] ~]# chkconfig--add mysqld [Email protected] ~]# chkconfig--list Iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off Iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off Iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off Netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off Network 0:off 1:off 2:on 3:on 4:on 5:on 6:off Check Port [Email protected] ~]# NETSTAT-TULNP | grep 3306 TCP6 0 0::: 3306:::* LISTEN 21466/mysqld |
10. Set Environment variables path path
[Email protected]/]# Vi/etc/profile --INSERT-- Path=/usr/local/mysql/bin: $PATH Export PATH : Wq "/etc/profile" # Source/etc/profile |
11, Enter the database error
[Email protected]/]# Mysql-uroot ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket ' Mysql.mysql ' (2) |
12. Edit my.cnf
[Email protected] ~]# VI/ETC/MY.CNF [Mysqld] Basedir=/usr/local/mysql Datadir=/data/mydata port=3306 Socket=/data/mydata/mysql.sock Server_id=1 [Mysqld_safe] Log-error=/data/log/mysqld.log [MySQL] Socket=/data/mydata/mysql.sock [Mysqldump] Socket=/data/mydata/mysql.sock [Mysqladmin] Socket=/data/mydata/mysql.sock |
13. Restart mysqld service
# etc/init.d/mysqld Restart |
Enter the database and set the password
# Mysql–uroot mysql> Set Password = password (' 123456 '); Query OK, 0 rows Affected (0.00 sec) Mysql> quit Bye |
Here, the database installation is complete.
Thank you for your Danale blog. Reference links
Http://www.aiezu.com/db/mysql_cant_connect_through_socket.html
http://blog.csdn.net/xiagege3/article/details/41852895
http://blog.csdn.net/hengrjgc/article/details/40299213
http://wilr.iteye.com/blog/2168659
Http://www.cnblogs.com/xiongpq/p/3384681.html
http://msnvip.iteye.com/blog/542004
Http://blog.sina.com.cn/s/blog_637e04c9010117ri.html
Http://www.cnblogs.com/fuhj02/p/3541173.html
This article is from the "Cheng Zi" blog, make sure to keep this source http://jif521.blog.51cto.com/848361/1597899
Centos 7 source code compile and install MySQL 5.6.22 (finishing article)