Compiling and installing mysql-5.5.37

Source: Internet
Author: User

First, the environment

System: CentOS 6.4x64 Minimized installation

ip:192.168.3.54

Second, install the basic package

[Email protected] conf]# yum-y install make gcc-c++ cmake bison-devel ncurses-devel

Third, install MySQL

1. Create a user

[[email protected] ~]# groupadd mysql[[email protected] ~]# useradd-g MySQL mysql-s/sbin/nologin

2. Unpacking the Package

[Email protected] ~]# Tar XF mysql-5.5.37.tar.gz

3. Compiling configuration parameters

 #创建用来存放Mysql数据的目录 [[email protected] ~]# mkdir -p  /data/mysql/data[[email protected] ~]# cd mysql-5.5.37[[email protected]  Mysql-5.5.37]# cmake > -dcmake_install_prefix=/usr/local/mysql-5.5.37 > -dmysql _datadir=/data/mysql/data > -dsysconfdir=/etc > -dwith_myisam_storage_engine=1  > -dwith_innobase_storage_engine=1 > -dwith_memory_storage_engine=1 > -dwith _readline=1 > -dmysql_unix_addr=/var/lib/mysql/mysql.sock > -dmysql_tcp_port=3306  > -denabled_local_infile=1 > -dwith_partition_storage_engine=1 > - dextra_charsets=all > -ddefault_charset=utf8 > -ddefault_collation=utf8_general_ci[[ Email protected] mysql-5.5.37]# make && make install 

    4. Data Catalog Initialization

[[email protected] mysql-5.5.37]# cd /usr/local/mysql-5.5.37/[[email protected]  Mysql-5.5.37]# scripts/mysql_install_db --datadir=/data/mysql/data/ --user=mysql --basedir =/usr/local/mysql-5.5.37/installing mysql system tables ... Okfilling help tables ... ok                              #到这里显示的有2个OK表示成功To  start mysqld at  boot time you have to copysupport-files/mysql.server to the  Right place for your systemplease remember to set a password  for the mysql root user ! to do so, start the server, then issue the following  Commands:/usr/local/mysql-5.5.37//bin/mysqladmin -u root password&nbsP; ' New-password '/usr/local/mysql-5.5.37//bin/mysqladmin -u root -h httpd password  ' New-password ' Alternatively you can run:/usr/local/mysql-5.5.37//bin/mysql_secure_ Installationwhich will also give you the option of removing the  testdatabases and anonymous user created by default.  This  Isstrongly recommended for production servers. See the manual for more instructions. you can start the mysql daemon with:cd /usr/local/mysql-5.5.37/ ;  /usr/local/mysql-5.5.37//bin/mysqld_safe &You can test the MySQL  daemon with mysql-test-run.plcd /usr/local/mysql-5.5.37//mysql-test ; perl  mysql-test-run.plplease report any problems at http://bugs.mysql.com/

5. Copy the MySQL configuration file

[Email protected] mysql-5.5.37]# CP-RF support-files/my-large.cnf/etc/my.cnf

6. Create a startup script

[[email protected] mysql-5.5.37]# CP Support-files/mysql.server/etc/init.d/mysqld[[email protected] mysql-5.5.37]# chmod +x/etc/init.d/mysqld[[email protected] mysql-5.5.37]#/etc/init.d/mysqld startstarting MySQL. success!                   [[email protected] mysql-5.5.37]# NETSTAT-ANPT |grep mysqltcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 21814/mysqld

7. Connect to a database

[[email protected] ~]# which mysql/usr/bin/which: no mysql in  (/usr/ Local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin) #配置软连接 [[email protected] ~]#  Ln -s /usr/local/mysql-5.5.37/ /usr/local/mysql[[email protected] ~]# ln -s  /usr/local/mysql-5.5.37/bin/* /usr/sbin/[[email protected] ~]# which mysql/usr/ Sbin/mysql Connect to the database [[Email protected] ~]# mysqlwelcome to the mysql monitor.   commands end with ; or \g.your mysql connection id is  1Server version: 5.5.37-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&nBsp;may be trademarks of their respectiveowners. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>  #默认的情况下是没有密码的, set the root account password, set the password is Ly36843mysql> update user set  password=password (' lyao36843 ')  where host= "localhost"  and user= "root"; query ok, 1 row affected  (0.03 sec) rows matched: 1  changed:  1  warnings: 0mysql> update user set password=password (' lyao36843 ' )  where host= "127.0.0.1"  and user= "root"; query ok, 1 row affected  (0.00 sec) rows matched: 1  changed:  1  warnings: 0mysql> select user,host,password from mysql.user;+-- ----+-----------+-------------------------------------------+| user | host      | password                                    |+------+-----------+-------------------------------------------+|  root | localhost | *b181a5bca7c882221f5b8f6f9657ae71ff67eddb | |  root | httpd     |                                             | |  root | 127.0.0.1 | *b181a5bca7c882221f5b8f6f9657ae71ff67eddb | |  root | ::1       |                                             | |       | localhost |                                             | |       | httpd     |                                              |+------+-----------+-------------------------------------------+6 rows in set   (0.00 sec) #清除mysql用户表中不安全的用户mysql > DELETE FROM MYSQL.USER WHERE&NBsp;password= "; query ok, 4 rows affected  (0.03 sec) Mysql> select user,host, password from mysql.user;+------+-----------+-------------------------------------------+| user  | host      | password                                    |+------+-----------+----------------------------------- --------+| root | localhost | *b181a5bca7c882221f5b8f6f9657ae71ff67eddb | |  root | 127.0.0.1 | *b181a5bca7c882221f5b8f6f9657ae71ff67eddb |+------+--------- --+-------------------------------------------+2 rows in set  (0.00 sec) mysql>  flush privileges; query ok, 0 rows affected  (0.00 SEC) #退出数据库重新连接 [[Email protected] ~]# mysql -u root -p -h 127.0.0.1enter password:                   #输入之前设置的mysql数据库密码Welcome  to the mysql monitor.  commands end with ; or \g.your  MySQL connection id is 2Server version: 5.5.37-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>

8. Finally add MySQL to boot auto-start

[[email protected] ~]# chkconfig--add mysqld[[email protected] ~]# chkconfig mysqld on[[email protected] ~]# chkconfig my Sqld--listmysqld 0:off1:off2:on3:on4:on5:on6:off


This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1642561

Compiling and installing mysql-5.5.37

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.