Reference: http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html
Http://www.cnblogs.com/xiongpq/p/3384681.html
First, install CMake (mysql5.5.0 after the version with CMake installation )
Download:
Cd/usr/local/src/wget http://www.cmake.org/files/v3.3/cmake-3.3.0-rc4.tar.gz
Installation:
TAR-ZXVF cmake-3.3.0-rc4.tar.gzcd Cmake-3.3.0-rc4./configuremakemake Install
Second, installation mysql-5.5.40
(1) Create MySQL installation directory and data storage directory
Mkdir/usr/local/mysqlmkdir/usr/local/mysql/data
(2) Create MySQL users and user groups
Groupadd mysqluseradd-r-G MySQL MySQL
(3) Installing MySQL
Because there is just one mysql-5.5.40 version of the database on the company Linux server, I used it directly. But you need to download the must choose version 5.5.0 or later
TAR-ZXVF mysql-5.5.40.tar.gzcd Mysql-5.5.40cmake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dextra_charsets=all-denabled_local_infile=1
Make
Make install
Description of the parameters in. CMake:
-dcmake_install_prefix=/usr/local/mysql//installation directory (default installation path:/usr/local/mysql)
-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
PS. Note: If you recompile, you need to clear the old object file and cache information
#make Clean
#find/-name CMakeCache.txt the command to find all CMakeCache.txt files, and then use the command to delete the
#rm-f ..../cmakecache.txt
#rm-rf/etc/my.cnf
(4) configuration ( emphasis )
#设置目录权限
Cd/usr/local/mysqlchown-r Root:mysql. Chown-r Mysql:mysql Data
#将mysql的启动服务添加到系统服务中
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MYSQL.CNF
#增加mysql数据库的使用者
scripts/mysql_install_db--user=mysql
#设置环境变量
Vi/root/.bash_profile
#在环境变量PATH =$PATH: append parameters after $HOME/bin, appended as follows:
#PATH =$PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
#让配置立即生效
Source/root/.bash_profile
(5) Start MySQL
1) manual Start (recommended)
Cd/usr/local/mysql
#启动MySQL, the exit command does not stop automatically after it starts, but we can press ENTER to exit
Mysql
Mysqladmin-u root-p shutdown #这里需要输入MySQL的root用户密码, because there is no setting, so the direct return to
PS: error message 1, 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)
Workaround: This is not starting the MySQL service, so you must start the service before you can enter MySQL
2) Add MySQL to the system service
#将mysql的启动服务增加到系统服务中去cp Support-files/mysql.server/etc/init.d/mysql
Chkconfig MySQL on
PS: 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/ In Support-files/mysql.server
#启动服务service MySQL Start
Then you'll see "starting MySQL. Success! " The word, that MySQL has been started.
(6) Configure user
After MySQL starts successfully, Root does not have a password, we need to set the root password.
Before setting it, we need to set the path so that it directly calls the MySQL
vi/etc/profile# Press shift+g key to jump to the end of the file, add Path=/usr/local/mysql/bin at the end: $PATHexport PATH#:WQ exit, let the configuration take effect immediately source/etc/profile
Now enter the MySQL environment
#使用root用户登陆mysql-uroot #给root用户设置密码mysql >set PASSWORD = PASSWORD (' 123456 ');
To set the root user to have remote access, perform
Mysql> GRANT All privileges on * * to ' root ' @ ' 172.16.% ' identified by 'password' with GRANT OPTION;
# # red password for remote access, the root user's password can be different from the local.
(7) firewall configuration
Firewall 3306 port is not enabled by default, to remote access, you need to open this port
vi/etc/sysconfig/iptables# find "-A input–m State--state new–m tcp–p–dport 22–j ACCEPT" This line, and then add a line below:-A input-m State- -state new-m tcp-p-dport 3306-j accept,:wq Save exit # Restart, refresh firewall configuration service iptables restart
At this point, all configuration is complete.
We can enter MySQL, but this is the need to enter a password, the command is as follows:
Mysql-uroot-p
#然后输入密码即刻进入
Third, Linux under the full installation of MySQL