6、單機運行環境搭建之 --CentOS-6.4安裝MySQL 5.6.10並修改MySQL的root使用者密碼

來源:互聯網
上載者:User

Mysql 5.5以後使用了CMake進行安裝,參考與以前的區別請參考:

http://www.blogjava.net/kelly859/archive/2012/09/04/387005.html

 

接上文。

1:下載:當前mysql版本到了5.6.10

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/

2:必要軟體包

yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake

 

# 新增使用者組
groupadd mysql

 

# 新增使用者
useradd mysql -g mysql

 

# 建立資料庫執行檔案目錄
mkdir -p /usr/local/mysql

 

# 建立資料庫資料檔案目錄
mkdir -p /db/mysql/data

 

# 修改目錄擁有者

chown -R mysql:mysql /usr/local/mysql

chown -R mysql:mysql /db/mysql/data

chown -R mysql:mysql /usr/local/mysql/.

chown -R mysql:mysql /db/mysql/data/.

 

# 編輯PATH搜尋路徑
vi /etc/profile
添加如下兩行:

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH

# 生效PATH搜尋路徑
source /etc/profile

 

# 安裝編譯源碼所需的工具和庫
yum -y install wget gcc-c++ ncurses-devel cmake make perl

# 進入源碼壓縮包下載目錄
cd /usr/src

# 下載源碼壓縮包
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/

# 解壓縮源碼包
tar -zxv -f mysql-5.6.10.tar.gz

# 進入解壓縮源碼目錄

cd mysql-5.6.10

# 編譯並安裝

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/db/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

-DWITH_DEBUG=0
make && make install

紅色部分表示禁用Debug模式。

# 複製設定檔
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

# 進入安裝路徑
cd /usr/local/mysql

# 執行配置指令碼
scripts/mysql_install_db --user=mysql --datadir=/db/mysql/data

# 複製服務啟動指令碼
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

# 啟動MySQL服務
service mysql start

# 設定開機自動啟動服務
chkconfig mysql on

>>>>>>>>>>>>>>>完成

如果發生如下錯誤:

[root@rekfan mysql]# service mysql restart
MySQL server PID file could not be found![失敗]
Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/rekfan.pid).[失敗]

 黃海的問題解決辦法是:

killall命令 killall命令殺死同一進程組內的所有進程。其允許指定要終止的進程的名稱,而非PID。 # killall mysqld 再次查看mysqld進程: ps -ef|grep mysqld 沒有了!世界清靜了。 

 

運行 mysql

然後進入mysql> 提示符後,輸入status;

查看安裝情況。

mysql> status;--------------mysql  Ver 14.14 Distrib 5.6.10, for Linux (x86_64) using  EditLine wrapperConnection id:          1Current database:Current user:           root@localhostSSL:                    Not in useCurrent pager:          stdoutUsing outfile:          ''Using delimiter:        ;Server version:         5.6.10 Source distributionProtocol version:       10Connection:             Localhost via UNIX socketServer characterset:    latin1Db     characterset:    latin1Client characterset:    latin1Conn.  characterset:    latin1UNIX socket:            /tmp/mysql.sockUptime:                 7 secThreads: 1  Questions: 5  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 0.714--------------

 #表名全部為小寫,避免出現大小寫敏感

 vi /etc/my.cnf 添加如下內容,解決大小寫表名敏感問題。

lower_case_table_names=1

 

修改MySQL的root使用者的密碼以及開啟遠端連線

mysql 

mysql> use mysql;

mysql> desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //為root添加遠端連線的能力
mysql> update user set Password = password('123456') where User='root'; //設定root使用者密碼

mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit

 

 

附自動安裝指令碼如下:

vi installmysql.shchmod 777 installmysql.sh./installmysql.sh

 

內容如下:

yum -y install wget gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake perlgroupadd mysqluseradd mysql -g mysqlmkdir -p /usr/local/mysqlmkdir -p /db/mysql/datachown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /db/mysql/datachown -R mysql:mysql /usr/local/mysql/.chown -R mysql:mysql /db/mysql/data/.echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:\$PATH" >> /etc/profileecho "export PATH" >> /etc/profilesource /etc/profilecd /usr/software/#下載mysql源碼包#wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/tar -zxvf mysql-5.6.10.tar.gzcd /usr/software/mysql-5.6.10cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/db/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306make && make installcp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnfcd /usr/local/mysqlscripts/mysql_install_db --user=mysql --datadir=/db/mysql/datacp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlecho "lower_case_table_names=1" >> /etc/my.cnfservice mysql startchkconfig mysql onmysqladmin -u root password 'dsideal'service iptables stopchkconfig iptables offsed -i 's#SELINUX=enforcing#SELINUX=disabled#'g /etc/sysconfig/selinux

 

相關文章

聯繫我們

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