背景:
系统为redhat6.5最小化安装系统,配好本地yum源
yum -y install gcc gcc-c++ pcre-devel openssl-devel glibc make cmake ncurses ncurses-devel libtool zilib-devel libaio-devel bison-devel sssd
yum groupinstall Development tools
mysql版本为 mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz这个版本和官网上的不太一样
下载地址http://pan.baidu.com/s/1eRbcYrS
提取码5d2n
Redhat6.5安装mysql5.7.9
1、 新增mysql用户组
# groupadd mysql
新增mysql用户
# useradd -r -g mysql mysql
新建数据库数据文件目录
# mkdir -p /home/mysql
# mkdir -p /home/mysql/data
# mkdir -p /home/mysql/logs
2、 将tar 包拷贝到mysql的home 目录下,进行解压后得到的目录 重命名为 mysql-5.7.9
3、 进入 /home/mysql/mysql-5.7.9/bin
[root@localhost bin]$ ./mysql_install_db --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data
[WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
[ERROR] The bootstrap log isn't empty:
[ERROR] 2015-11-19T14:49:01.852039Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
[Warning] Changed limits: max_open_files: 1024 (requested 5000)
[Warning] Changed limits: table_open_cache: 431 (requested 2000)
[ERROR] Can't read from messagefile'/usr/share/mysql/english/errmsg.sys'
提示mysql_install_db 命令已弃用,使用mysqld
[root@localhost bin]$ ./mysqld --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data
配置文件
[root@localhost ~]# cd /home/mysql/mysql-5.7.9/support-files/
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? yes
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql
basedir=/home/mysql/mysql-5.7.9
datadir=/home/mysql/data
vi /etc/profile
export MYSQL_HOME="/home/mysql/mysql-5.7.9"
export PATH="$PATH:$MYSQL_HOME/bin"
source /etc/profile
su - mysql
[mysql@localhost ~]$ service mysql start
Starting MySQL. SUCCESS!
初始化mysql
密码在/root/ .mysql_secret
Mysql -u root -p
改密码
set password for root@"localhost"=password("123");
授权
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
flush privileges;