MySQL學習筆記(基礎部分)-單一實例mysql-5.5.X安裝

來源:互聯網
上載者:User

標籤:

MySQL學習筆記(平台CentOS 6)

1、建立mysql帳號

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

2、配置安裝環境

[[email protected] ~]# yum groupinstall ‘Development Tools‘ -y[[email protected] ~]# yum install gcc gcc-c++ make ncurses-devel bison perl -y # 依賴包

    安裝cmake

[[email protected] tools]# tar -zxf cmake-2.8.12.tar.gz# 安裝cmake[[email protected] tools]# cd cmake-2.8.12[[email protected] cmake-2.8.12]# ./configure[[email protected] cmake-2.8.12]# gmake[[email protected] cmake-2.8.12]# gmake install[[email protected] cmake-2.8.12]# which cmake# 配置cmake環境變數/usr/local/bin/cmake[[email protected] cmake-2.8.12]# echo ‘export PATH=/usr/local/bin:$PATH‘ >> /etc/profile[[email protected] cmake-2.8.12]# source /etc/profile

    此處cmake,也可以通過“yum install cmake -y”安裝,但是這種方式安裝的“cmake”,在編譯mysql時會有警告:

CMake Warning (dev) in sql/CMakeLists.txt:  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the  cmake_policy command to set the policy and suppress this warning.  Target "mysqld" has an INTERFACE_LINK_LIBRARIES property which differs from  its LINK_INTERFACE_LIBRARIES properties.  INTERFACE_LINK_LIBRARIES:-lpthread;sql;mysys  LINK_INTERFACE_LIBRARIES:rtThis warning is for project developers.  Use -Wno-dev to suppress it.-- Generating done-- Build files have been written to: /root/tools/mysql-5.5.37

3、建立安裝目錄

[[email protected] ~]# mkdir -p /usr/local/mysql        # 安裝目錄[[email protected] ~]# mkdir /db/mysql -p               # 資料存放區目錄                 [[email protected] ~]# chown -R mysql.mysql /usr/local/mysql[[email protected] ~]# chown -R mysql.mysql /db

4、安裝mysql

[[email protected] tools]# tar -zxf mysql-5.5.37.tar.gz[[email protected] tools]# cd mysql-5.5.37[[email protected] mysql-5.5.37]# cmake > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \        # mysql安裝路徑> -DMYSQL_DATADIR=/db/mysql/ \# mysql資料存放區路徑> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \# 指定sock位置> -DMYSQL_TCP_PORT=3306 \# 指定連接埠> -DEXTRA_CHARSETS=all \# 安裝所有字元集> -DENABLED_LOCAL_INFILE=ON > -DWITH_INNOBASE_STORAGE_ENGINE=1 > -DWITH_FEDERATED_STORAGE_ENGINE=1 > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 > -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 > -DWITHOUT_PARTITION_STORAGE_ENGINE=1 > -DWITH_FAST_MUTEXES=1 > -DWITH_ZLIB=bundled > -DENABLED_LOCAL_INFILE=1 > -DWITH_READLINE=1 > -DWITH_EMBEDDED_SERVER=1 > -DWITH_DEBUG=0[[email protected] mysql-5.5.37]# make && make install

    copy mysql設定檔,產生資料檔案

[[email protected] mysql-5.5.37]# ll support-files/*.cnf-rw-r--r-- 1 root root  4667 Aug 18 07:30 support-files/my-huge.cnf-rw-r--r-- 1 root root 19759 Aug 18 07:30 support-files/my-innodb-heavy-4G.cnf-rw-r--r-- 1 root root  4641 Aug 18 07:30 support-files/my-large.cnf-rw-r--r-- 1 root root  4652 Aug 18 07:30 support-files/my-medium.cnf-rw-r--r-- 1 root root  2816 Aug 18 07:30 support-files/my-small.cnf[[email protected] mysql-5.5.37]# /bin/cp support-files/my-small.cnf /etc/my.cnf
[[email protected] ~]# chown -R mysql.mysql /usr/local/mysql[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql  --datadir=/db/mysql --user=mysql

5、啟動mysql

[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql &[[email protected] ~]# netstat -ntulp | grep mysqldtcp        0    0 0.0.0.0:3306       0.0.0.0:*         LISTEN      38437/mysqld

6、安裝後配置

[[email protected] ~]# echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >>/etc/profile[[email protected] ~]# source /etc/profile[[email protected] mysql-5.5.37]# cp support-files/mysql.server /etc/init.d/mysqld[[email protected] ~]# chmod 700 /etc/init.d/mysqld[[email protected] ~]# /etc/init.d/mysqld stop[[email protected] ~]# chkconfig --add mysqld[[email protected] ~]# chkconfig mysqld on

7、mysql配置密碼

[[email protected] ~]# /etc/init.d/mysqld start[[email protected] ~]# mysqladmin -uroot password ‘q.1234‘



MySQL學習筆記(基礎部分)-單一實例mysql-5.5.X安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.