1. yum 升级
yum install cmake make apr* autoconf automake gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch
2.wget (PHPlibmcrypt模块)
安装之
3.安装mysql 准备:
groupadd mysql
useradd -g mysql mysql -s /bin/false
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
mkdir -p /usr/local/mysql
4.安装:
./configure --prefix=/usr/local/mysql --localstatedir=/data/mysql --without-debug --with-charset=utf8 --with-extra-charsets=all --enable-assembler --with-pthread --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-big-tables --with-plugins=all
make && make install
5.后续操作:
(1)配置文件更新:
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
vi /etc/my.cnf #编辑配置文件,在 [mysqld] 部分增加下面一行
datadir = /data/mysql #添加MySQL数据库路径
default-character-set=utf8
skip-character-set-client-handshake
wait_timeout=864000
interactive-timeout=864000
max_connections=2000
(2) 初始化数据库:
/usr/local/mysql/bin/mysql_install_db --user=mysql
(3)系统启动方面的工作:
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql #增加执行权限
chkconfig mysql on #加入开机启动
vi /etc/rc.d/init.d/mysql #编辑
basedir = /usr/local/mysql #MySQL程序安装路径
datadir = /data/mysql #MySQl数据库存放目录
vi /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/usr/local/mysql/bin
下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
(4)后续工作
service mysql start
设置密码 :
/usr/local/mysql/bin/mysqladmin -uroot password 'abc'
mysql -uroot -p
SHOW VARIABLES LIKE '%character%';
show engines;
远程访问mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY 'yourpasswd' WITH GRANT OPTION;
mysql> flush privileges;
********************************
如何取消远程访问mysql
停止mysql服务,然后用下面的方式启动mysql:
mysqld --skip-grant-tables
或
mysqld-nt --skip-grant-tables
(以上2个命令根据不同版本选择其中一个合适的运行就可以)
然后就用mysql客户端直接服务器本地登陆mysql(不用密码的),然后增加本地的登陆帐号即可:
grant all on *.* to IDENTIFIED BY '密码' with grant option;
flush privlieges;
grant all on *.* to IDENTIFIED BY '密码' with grant option;
flush privlieges;
接着kill掉上面启动的mysql服务进程,重新按平时正常的方式启动mysql即可.
阅读(3221) | 评论(0) | 转发(0) |