編譯安裝mysql-5.5.37

來源:互聯網
上載者:User

標籤:編譯安裝mysql-5.5.37

一、環境

    系統:CentOS 6.4x64迷你安裝

    IP:192.168.3.54

二、安裝基礎軟體包

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

三、安裝mysql

    1.建立使用者

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

    2.解壓軟體包

[[email protected] ~]# tar xf mysql-5.5.37.tar.gz

    3.編譯配置參數

#建立用來存放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.資料目錄初始化

[[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 ‘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.複製mysql設定檔

[[email protected] mysql-5.5.37]# cp -rf support-files/my-large.cnf /etc/my.cnf

    6.建立啟動指令碼

[[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.串連到資料庫

[[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串連到資料庫[[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 may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> #預設的情況下是沒有密碼的,設定root帳號的密碼,設定密碼是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 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.最後將mysql添加到開機自動啟動

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


本文出自 “ly36843營運” 部落格,請務必保留此出處http://ly36843.blog.51cto.com/3120113/1642561

編譯安裝mysql-5.5.37

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.