[教程]centos卸載、安裝mysql(源碼編譯安裝方式)

來源:互聯網
上載者:User

標籤:

-----------1 卸載系統內建的msyql包 
rpm -qa|grep mysql


rpm -e --nodeps mysql-server-5.1.71-1.el6.x86_64 --強制卸載mysql安裝程式
rpm -e mysql-server-5.1.71-1.el6.x86_64 -- 有依賴關係,無法卸載


---------- 2 安裝cmake 編譯軟體 mysql5.6開始不使用configure 方式 
yum -y install cmake make


---------- 3 安裝mysql 的依賴包,其他linux 需要一個個軟體下載 編譯安裝 
yum install gcc gcc-c++ autoconf bison automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* -y


---------- 4 建立mysql 目錄 存放日誌和資料檔案等 並更改目錄擁有者
mkdir /mysql 
mkdir /mysql/data
mkdir /mysql/logs
mkdir /mysql/data/socket
chown mysql.mysql -R /mysql

---------- 5 建立mysql使用者並不允許登入系統
groupadd mysql 
useradd mysql -g mysql -s /sbin/nologin


---------- 6 解壓(需要切換到mysql-5.6.19.tar.gz的存放目錄)
tar -zxvf mysql-5.6.19.tar.gz


---------- 7 進入mysql解壓目錄
cd mysql-5.6.19


---------- 8 編譯 
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/mysql/data/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/mysql/data/ \
-DMYSQL_USER=root \
-DMYSQL_TCP_PORT=3306

--------- 9 make 安裝 
make

--------- 10 make 安裝 
make install 

--------- 11 負載啟動命令道系統啟動目錄 
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld

--------- 12 設定為開機啟動 chkconfig --list|grep mysqld 檢測是否已經設定為開機啟動
chkconfig mysqld on


--------- 13 複製mysql命令道系統內容變數
cp /usr/local/mysql/bin/mysql /usr/bin/mysql
cp /usr/local/mysql/bin/mysql /usr/local/bin/mysql

--------- 14 初始化mysql系統資料庫 (需要回到/根目錄執行)
./usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data

 

--------- 15 mysql 修改密碼 -------------------------
> use mysql;
> UPDATE user SET password=PASSWORD(‘[email protected]#123txt‘);
> FLUSH PRIVILEGES;

--------- 16 刪除不必要的用於
> delete from user where host <> ‘localhost‘;
> update user set host=‘%‘; 
> FLUSH PRIVILEGES;

 


--------------------------------------------附---------------------------------------------
grant all privileges on *.* to [email protected]‘%‘ identified by "[email protected]#123txt";


vi /etc/my.cnf


[mysqld]

innodb_file_per_table=ON
skip-name-resolve
skip-grant-tables
port=3306


wait_timeout=315360000
interactive_timeout=315360000


basedir=/usr/local/mysql

datadir=/mysql/data/

log-error=/mysql/logs/mysql.log

socket=/mysql/data/socket/mysql.sock

lower_case_table_names=1
character-set-server=utf8
open_files_limit=102400

back_log=600

max_connections=10000
max_connect_errors=6000

sort_buffer_size=2M

max_allowed_packet=64M

thread_cache_size=256
thread_concurrency=16

binlog_format = row
log-bin=mysql-bin

 

#innodb config
innodb_buffer_pool_size=4096M
#innodb_file_io_threads=8
innodb_read_io_threads=8
innodb_write_io_threads=8
innodb_log_buffer_size=32M
innodb_log_file_size=2048M
innodb_log_files_in_group=3
innodb_max_dirty_pages_pct=90

innodb_lock_wait_timeout=300

explicit_defaults_for_timestamp=true

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[client]
socket=/mysql/data/socket/mysql.sock
default-character-set=utf8
port=3306

[教程]centos卸載、安裝mysql(源碼編譯安裝方式)

聯繫我們

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