CentOS 6.4 64-bit Platform mysql5.5.36 source compilation installation

Source: Internet
Author: User
Tags php website reserved administrator password

Directory

1. System environment

2. Prepare user and data storage directory

3. Compile and install MySQL

4. Initial security configuration of MySQL database

5, the MySQL Administrator password loss processing

1. System environment

[Email protected]_server ~]# Cat/etc/issuecentos Release 6.4 (Final) Kernel \ r on an \m[[email protected]_server ~]# UNAM E-R2.6.32-358.EL6.X86_64 has installed the system with "development tools" and "Server Platform Development" Two development pack groups. [Email protected]_server ~]# yum-y Install CMake #mysql5.5 is no longer made to compile, but Cmake[[email protected]_server software]# pwd /root/software[[email protected]_server software]# lsmysql-5.5.36.tar.gz[[email protected]_server software]# Tar XF Mysql-5.5.36.tar.gz[[email protected]_server software]# lsmysql-5.5.36 mysql-5.5.36.tar.gz

If the system comes with an RPM package installed MySQL database then uninstall it first:

[Email protected]_server software]# rpm-qa mysqlmysql-5.1.73-3.el6_5.x86_64[[email protected]_server software]# rpm- E--nodeps MySQL

2, prepare users and data storage directory

2.1. Create user

[Email protected]_server software]# useradd-r mysqluseradd:user ' MySQL ' already exists #mysql用户已存在 [[Email protected]_s erver software]# ID mysqluid=27 (mysql) gid=27 (MySQL) groups=27 (MySQL)

2.2. Create a data storage directory

[Email protected]_server software]# mkdir-pv/mydata/data #在生产环境上就建立在LVM卷或存储设备映射过来的卷上mkdir: Created directory '/ Mydata/data ' [[email protected]_server software]# chown-r mysql.mysql/mydata/data #修改数据目录的属主与属组

3. Compile and install

[[email protected]_server software]# cd mysql-5.5.36[[email protected]_server  mysql-5.5.36]# cmake . -dcmake_install_prefix=/opt/lamp/mysql55/ -dmysql_datadir=/mydata/ Data -dmysql_unix_addr=/tmp/mysql.sock -dsysconfdir=/etc -dwith_innobase_storage_engine=on  -dwith_archive_storage_engine=on -dwith_blackhole_storage_engine=on -dwith_readline=on - Dwith_ssl=system -dwith_zlib=system -dwith_libwrap=off -ddefault_charset=utf8 -dextra=all  -ddefault_collation=utf8_general_ci[[email protected]_server mysql-5.5.36]# make[[email  protected]_server mysql-5.5.36]# make install[[email protected]_server  Mysql-5.5.36]# cd /opt/lamp/mysql55/[[email protected]_server mysql55]# chgrp -r  mysql . [email protected]_server mysql55]# cp support-files/my-large.cnf /etc/my.cnf     #提供Configuration files cp: overwrite  '/etc/my.cnf '?  y[[email protected]_server mysql55]# vim / etc/my.cnf  #在 [mysqld] field, add the following parameter datadir = /mydata/data[[email protected]_server  mysql55]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld  clip   #提供服务脚本 [email  protected]_server mysql55]# chmod +x /etc/rc.d/init.d/mysqld[[email protected]_ server mysql55]# ./scripts/mysql_install_db --user=mysql --datadir=/mydata/data    #初始化数据库, see two "OK" to initialize success [[email protected]_server mysql55]# ls /mydata/data     #在没有启动mysqld服务时此目录有以下这些文件mysql   mysql-bin.000001  mysql-bin.000002   mysql-bin.index  performance_schema  test[[email protected]_server mysql55]#  service mysqld start   #启动服务Starting  mysql... success! [[Email protected]_server mysql55]# netstat -tnl   #查看3306端口是否监听 [[email protected]_server mysql55]# vim /etc/ profile.d/mysql.sh   #导出二进制文件export  path=/opt/lamp/mysql55/bin: $PATH [[Email protected]_ server mysql55]# source /etc/profile.d/mysql.sh[[email protected]_server mysql55]#  mysql  #测试能否连入mysqlWelcome  to the mysql monitor.  commands end  with ; or \g.your mysql connection id is 1server version:  5.5.36-log Source distributionCopyright  (c)  2000, 2014, oracle and/or  its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input statement.mysql>[[email protected]_server  mysql55]# ls /mydata/data    #启动mysqld服务后此目录下就会新增一些文件db_server. err  ibdata1       ib_logfile1  mysql-bin.000001  mysql-bin.000003   performance_schemadb_server.pid  ib_logfile0  mysql         mysql-bin.000002  mysql-bin.index   test

4. Initial security configuration of MySQL database

4.1. Delete anonymous Users

mysql> select user,host,password from mysql.user;  #查看数据库中的用户信息 +------+------------ +----------+| user | host       | password |+----- -+------------+----------+| root | localhost  |           | |  root | db\_server |          | |  root | 127.0.0.1  |          | |  root | ::1        |           | |       | localhost  |           | |       | db\_server |           |+------+------------+----------+6 rows in set  (0.01 sec) mysql> drop user  ' @ ' localhost ';   #删除一个匿名用户mysql >  drop user  ' @ ' db\_server ';   #删除另一个匿名用户

If this database is not planned to be accessed by the IPV6 address, the root user can be removed to access the database IPV6, so the following actions:

mysql> drop user ' root ':: 1 ';mysql> select User,host,password from Mysql.user; #用户删除后的用户信息 +------+------------+----------+| user | Host | Password |+------+------------+----------+| Root |          localhost | || Root |          Db\_server | || Root |          127.0.0.1 | |+------+------------+----------+3 rows in Set (0.00 sec)

4.2. Change the root user password

    above only the ' root ' user each three host name combined into three kinds of users access to MySQL, the three means for MySQL is three different users, if the access password of the three users are the same, it can be directly in the SQL language call " Password () "function to uniformly modify the value of the" Password "field in the user table, as follows:

Mysql> update user set password=password (' 111111 ')  where user= ' root '; query ok, 3 rows affected  (0.02 sec) rows matched: 3  changed : 3  warnings: 0mysql> select user,host,password from mysql.user;   #查看密码是否修改成功 +------+------------+-------------------------------------------+| user | host        | password                                    |+------+------------+---------------------------------------- ---+| root | localhost  | *fd571203974ba9afe270fe62151ae967eca5e0aa | |  root | db\_server | *fd571203974ba9afe270fe62151ae967eca5e0aa | |  root | 127.0.0.1  | *fd571203974ba9afe270fe62151ae967eca5e0aa |+------+------------+------------------------------------- ------+3 rows in set  (0.02 sec) mysql> flush privileges;  #刷新授权表, Load the user's modified information into memory mysql> \qbye[[email protected]_server mysql55]# mysql  #测试ERROR  1045  (28000): access denied for user  ' root ' @ ' localhost '   (using  Password: no) [[email protected]_server mysql55]# mysql -uroot -p111111   welcome to the mysql monitor.  commands end with ; or  \g.Your MySQL connection id is 4Server version: 5.5.36-log  source distributioncopyright  (c)  2000, 2014, Oracle and/or its  Affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or itsaffiliates. other names may be trademarks of their  Respectiveowners. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>

4.3. Provide special authorized account for the application

MySQL root user can only be used for database management, not for the application, such as a PHP website program needs to interact with MySQL, it should create a user and give the appropriate permissions, specifically to interact with the site, must not use the root user.

5, the MySQL Administrator password loss processing

[[email protected]_server mysql55]# pwd/opt/lamp/mysql55[[email protected]_server  mysql55]# bin/mysqld_safe --skip-grant --skip-networking &   Explanation:--skip-grant       #表示启用时跳过授权表--skip-networking   #  to skip the network, the client communicates with mysqld without tcp/ IP mode, that is, do not listen to the local 3306 port, but only with the Uninx sock mode of communication, if not add this parameter, it will listen to the local port 3306, from a security point of view it is not safe. [[email protected]_server ~]# mysql    #无密码登陆mysqldWelcome  to the  mysql monitor.  commands end with ; or \g.your mysql  Connection id is 2server version: 5.5.36-log source distributioncopyright   (c)  2000, 2014, Oracle and/or its affiliates. All rights  Reserved. oracle is a registered trademark of oracle corporation and/or  itsaffiliates. other names may Be trademarks of their respectiveowners. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql> select user,host,password from mysql.user;+------+------------+ + ------------------------------------------+| user | host        | password                                    |+------+------------+-------------------------------------------+| root |  localhost  | *fd571203974ba9afe270fe62151ae967eca5e0aa | |  root | db\_server | *fd571203974ba9afe270fe62151ae967eca5e0aa | |  root | 127.0.0.1  | *fd571203974ba9afe270fe62151ae967eca5e0aa |+------+------------+-------------------------------------------+3 rows in set  (0.01 sec) MySQL > update mysql.user set password=password (' 123456 ')  where user= ' root ';    #修改密码Query  OK, 3 rows affected  (0.00 sec) rows matched: 3   Changed: 3  Warnings: 0[[email protected]_server ~]# service  mysqld restart   #重新启动mysqlShutting  down mysql. success! Starting mysql.  success! [[email protected]_server ~]# mysql -uroot -p123456    #之前是的密码是 "111111" , has now been modified to "123456" welcome to the mysql monitor.  commands end with  ;  or \g.your mysql connection id is 2server version: 5.5.36-log  Source distributionCopyright  (c)  2000, 2014, Oracle and/or its  Affiliates.  all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>

This article is from the "knowledge needs summary and records" blog, please be sure to keep this source http://zhaochj.blog.51cto.com/368705/1627142

CentOS 6.4 64-bit Platform mysql5.5.36 source compilation 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.