[教程]centos卸载、安装mysql(源码编译安装方式)

-----------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

 

cmake \
 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
 -DDEFAULT_CHARSET=utf8 \
 -DDEFAULT_COLLATION=utf8_general_ci \
 -DWITH_INNOBASE_STORAGE_engine=1 \
 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
 -DMYSQL_DATADIR=/data/mysqldb \
 -DMYSQL_TCP_PORT=3306 \
 -DENABLE_DOWNLOADS=1

--------- 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('txt!@#123txt');
> FLUSH PRIVILEGES;

--------- 16 删除不必要的用于
> delete from user where host <> 'localhost';
> update user set host='%'; 
> FLUSH PRIVILEGES;

 


--------------------------------------------附---------------------------------------------
grant all privileges on *.* to root@'%' identified by "txt!@#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

posted @ 2016-09-20 12:17  风儿飘  阅读(4430)  评论(0编辑  收藏  举报