mysql 编译安装

 

卸载旧版本

rpm -qa | grep mysql
rpm -e --nodeps mysql

下载MySQL 5.6.14

cd /usr/local/src
 wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.31.tar.gz
 tar -zxvf mysql-5.6.31.tar.gz
 cd mysql-5.6.31

准备

 #安装编译代码需要的包
 yum -y install make gcc-c++ cmake bison-devel ncurses-devel
 #添加用户和组
 groupadd -r mysql
 useradd -s /sbin/nologin -g mysql -r mysql
 id mysql

编译

 rm -f CMakeCache.txt
 mv /etc/my.cnf /etc/my.cnf.bak
 cmake \
 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/mysql-5.6.31 \
 -DMYSQL_DATADIR=/usr/local/mysql/mysql-5.6.31/data \
 -DSYSCONFDIR=/usr/local/mysql/mysql-5.6.31/etc \
 -DWITH_MYISAM_STORAGE_ENGINE=1 \
 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 -DWITH_MEMORY_STORAGE_ENGINE=1 \
 -DWITH_READLINE=1 \
 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql-5.6.31/mysql.sock \
 -DMYSQL_TCP_PORT=3306 \
 -DENABLED_LOCAL_INFILE=1 \
 -DWITH_PARTITION_STORAGE_ENGINE=1 \
 -DEXTRA_CHARSETS=all \
 -DDEFAULT_CHARSET=utf8 \
 -DDEFAULT_COLLATION=utf8_general_ci

make && make install

编译参数

http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

配置

 mkdir -p /usr/local/mysql/mysql-5.6.31

chown -R mysql:mysql /usr/local/mysql/mysql-5.6.31
cd /usr/local/mysql/mysql-5.6.31
yum -y install autoconf
mkdir logs
scripts/mysql_install_db --defaults-file=/usr/local/mysql/mysql-5.6.31/my.cnf.bak

显示

To start mysqld at boot time you have to copy
 support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/mysql-5.6.31//bin/mysqladmin -u root password ‘new-password’
/usr/local/mysql/mysql-5.6.31//bin/mysqladmin -u root -h webserver password ‘new-password’

Alternatively you can run:

/usr/local/mysql/mysql-5.6.31//bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; /usr/local/mysql/mysql-5.6.31//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file ./my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as ./my-new.cnf,
please compare it with your file and take the changes you need.

设置开机启动

 vim /etc/rc.local
 /usr/local/mysql/mysql-5.6.31/bin/mysqld_safe --defaults-file=/usr/local/mysql/mysql-5.6.31/my.cnf &
检查

启动mysql

/usr/local/mysql/mysql-5.6.31/bin/mysqld_safe --defaults-file=/usr/local/mysql/mysql-5.6.31/my.cnf &
ps aux|grep mysql
/usr/local/mysql/mysql-5.6.31/bin/mysqladmin -u root password 'new-password'
show VARIABLES like '%character%';

关闭mysql

/usr/local/mysql/mysql-5.6.31/bin/mysqladmin shutdown -u root -p

需改root密码 授权

use mysql;
UPDATE user SET Password = PASSWORD('123456') WHERE user = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by "123456" WITH GRANT OPTION;
FLUSH PRIVILEGES;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值