安裝前的準備工作,工具包的安裝
# yum -y install gcc libxml2-dev curl screen /libpng12-dev autoconf libpcre3-dev make bzip2 /libevent-dev patch libjpeg62-dev libcurl4-openssl-dev /libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz以下安裝中涉及的幾點需要提前說明的問題:
1. 所有下載的文件將保存在 /usr/local/software/ 目錄下
2. MySQL 將以mysql用戶運行,而且將加入 service 開機自動運行
3. mysql 將被安裝在 /usr/local/mysql/ 目錄下
4. mysql 默認安裝使用utf8 字符集
5. mysql 的數據和日志文件保存在 /var/mysql/ 對應目錄下
6. mysql 的配置文件保存于/var/mysql/my.cnf
自行下載安裝包:
m4-1.4.18.tar.gz
bison-2.5.tar.gz
cmake-2.8.8.tar.gz
mysql-5.6.10.tar.gz
首先可以查看下是否安裝了 cmake # rpm -qa |grep cmake
安裝 m4
# cd /usr/local/software# tar zxvf m4-1.4.18.tar.gz# cd m4-1.4.18# ./configure# make && make install安裝 cmake
# cd /usr/local/software# tar zxvf cmake-2.8.8.tar.gz# cd cmake-2.8.8# ./bootstrap# make && make install安裝 bison
# tar zxvf bison-2.5.tar.gz# cd bison-2.5# ./configure# make && make install創建mysql用戶及用戶組
# groupadd mysql# useradd -r -g mysql mysql編譯安裝 MySQL
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql /-DMYSQL_UNIX_ADDR=/tmp/mysql.sock /-DDEFAULT_CHARSET=utf8 /-DDEFAULT_COLLATION=utf8_general_ci /-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk /-DWITH_MYISAM_STORAGE_ENGINE=1 /-DWITH_INNOBASE_STORAGE_ENGINE=1 /-DWITH_MEMORY_STORAGE_ENGINE=1 /-DWITH_READLINE=1 /-DENABLED_LOCAL_INFILE=1 /-DENABLE_DOWNLOADS=1 /-DMYSQL_DATADIR=/var/mysql/data /-DMYSQL_USER=mysql
接下來,安裝:# make && make install注意事項:
重新編譯時,需要清除舊的對象文件和緩存信息。
# make clean# rm -f CMakeCache.txt# rm -rf /etc/my.cnf參數說明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安裝目錄
-DINSTALL_DATADIR=/usr/local/mysql/data //數據庫存放目錄
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校驗字符
-DEXTRA_CHARSETS=all //安裝所有擴展字符集
-DENABLED_LOCAL_INFILE=1 //允許從本地導入數據
分配權限:
# chmod +w /usr/local/mysql# chown -R mysql:mysql /usr/local/mysql# ln -s/usr/local/mysql/lib/libmysqlclient.so.18# /usr/lib/libmysqlclient.so.18創建相應的目錄:
# mkdir -p /var/mysql/# mkdir -p /var/mysql/data/# mkdir -p /var/mysql/log/# chown -R mysql:mysql /var/mysql/# cd support-files/# cp my-default.cnf /var/mysql/my.cnf# cp mysql.server /etc/init.d/mysqld配置啟動MySQL
# /usr/local/mysql/scripts/mysql_install_db /--defaults-file=/var/mysql/my.cnf /--basedir=/usr/local/mysql /--datadir=/var/mysql/data /--user=mysqlInstalling MySQL system tables...2017-02-07 10:29:30 26889 [Note] InnoDB: The InnoDB memory heap is disabled2017-02-07 10:29:30 26889 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2017-02-07 10:29:30 26889 [Note] InnoDB: Compressed tables use zlib 1.2.32017-02-07 10:29:30 26889 [Note] InnoDB: CPU does not support crc32 instructions2017-02-07 10:29:30 26889 [Note] InnoDB: Initializing buffer pool, size = 128.0M2017-02-07 10:29:30 26889 [Note] InnoDB: Completed initialization of buffer pool2017-02-07 10:29:30 26889 [Note] InnoDB: Highest supported file format is Barracuda.2017-02-07 10:29:30 26889 [Note] InnoDB: 128 rollback segment(s) are active.2017-02-07 10:29:30 26889 [Note] InnoDB: Waiting for purge to start2017-02-07 10:29:30 26889 [Note] InnoDB: 1.2.10 started; log sequence number 16260372017-02-07 10:29:30 26889 [Note] Binlog end2017-02-07 10:29:30 26889 [Note] InnoDB: FTS optimize thread exiting.2017-02-07 10:29:30 26889 [Note] InnoDB: Starting shutdown...2017-02-07 10:29:31 26889 [Note] InnoDB: Shutdown completed; log sequence number 1626047OKFilling help tables...2017-02-07 10:29:31 26914 [Note] InnoDB: The InnoDB memory heap is disabled2017-02-07 10:29:31 26914 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2017-02-07 10:29:31 26914 [Note] InnoDB: Compressed tables use zlib 1.2.32017-02-07 10:29:31 26914 [Note] InnoDB: CPU does not support crc32 instructions2017-02-07 10:29:31 26914 [Note] InnoDB: Initializing buffer pool, size = 128.0M2017-02-07 10:29:31 26914 [Note] InnoDB: Completed initialization of buffer pool2017-02-07 10:29:31 26914 [Note] InnoDB: Highest supported file format is Barracuda.2017-02-07 10:29:31 26914 [Note] InnoDB: 128 rollback segment(s) are active.2017-02-07 10:29:31 26914 [Note] InnoDB: Waiting for purge to start2017-02-07 10:29:31 26914 [Note] InnoDB: 1.2.10 started; log sequence number 16260472017-02-07 10:29:32 26914 [Note] Binlog end2017-02-07 10:29:32 26914 [Note] InnoDB: FTS optimize thread exiting.2017-02-07 10:29:32 26914 [Note] InnoDB: Starting shutdown...2017-02-07 10:29:33 26914 [Note] InnoDB: Shutdown completed; log sequence number 1626057OKTo 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/bin/mysqladmin -u root password 'new-password' /usr/local/mysql/bin/mysqladmin -u root -h iZ2zeg8zidyvg3jc1r0g6bZ password 'new-password'Alternatively you can run: /usr/local/mysql/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/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.plPlease report any problems with the ./bin/mysqlbug script!The latest information about MySQL is available on the web at http://www.mysql.comSupport MySQL by buying support/licenses at http://shop.mysql.comWARNING: Found existing config file /usr/local/mysql/my.cnf on the system.Because this file might be in use, it was not replaced,but was used in bootstrap (unless you used --defaults-file)and when you later start the server.The new default config file was created as /usr/local/mysql/my-new.cnf,please compare it with your file and take the changes you need.
將 mysql 加入開機啟動
chmod +x /etc/init.d/mysqldvi /etc/init.d/mysqld (編輯此文件,查找并修改以下變量內容:)basedir=/usr/local/mysqldatadir=/var/mysql/datachkconfig --add mysqldchkconfig --level 345 mysqld on啟動 mysql
# service mysqld start
Starting MySQL...[OK]
設置root用戶的密碼
/usr/local/mysql/bin/mysqladmin -u root password 'wise83680688!@#'
使用root用戶登錄
# /usr/local/mysql/bin/mysql -uroot -p
Enter password:【輸入密碼】
Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 5Server version: 5.6.10 Source distributionCopyright (c) 2000, 2013, 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用戶和密碼進行mysql的登錄了。可以開始使用了。
|
新聞熱點
疑難解答