linux centos7安装 mysql-5.7.11

1.下载和解压mysql数据库
 
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.11-linux-glibc2.5-x86_64.tar.gzs
 
tar -xvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /usr/local/mysql-5.7.11
 
2.建立软链接
ln -s mysql-5.7.11 mysql
 
 
3.创建mysql用户和修改软件的权限
 
   useradd -r -M -s /sbin/nologin mysql
 
   chown -R mysql.mysql  /usr/local/mysql-5.7.11
   chown -R mysql.mysql /usr/local/mysql
 
   chgrp -R mysql /usr/local/mysql-5.7.11
 
4.安装和初始化数据库
 
   cd /usr/local/mysql-5.7.11/
 
   bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.7.11/ --datadir=/usr/local/mysql-5.7.11/data/            --必须在mysql根目录安装mysql,否则出错
 
   cp -a ./support-files/my-default.cnf  /etc/my.cnf
 
   cp -a ./support-files/mysql.server  /etc/init.d/mysqld
 
  修改/etc/my.cnf
  basedir = /usr/local/mysql-5.7.11
    datadir = /usr/local/mysql-5.7.11/data
      port = 3306
 
   #cd bin/
   #./mysqld_safe --user=mysql & 
   
   [root@db2 scripts]# /etc/init.d/mysqld restart
   Shutting down MySQL..                                      [  OK  ]
   Starting MySQL...                                          [  OK  ]
 关闭是
 /etc/init.d/mysqld stop
 
  #开机启动
  chkconfig --level 35 mysqld on
 
5.初始化密码
 
mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。
 
shell> cat /root/.mysql_secret 
 
./mysql -uroot -p 
 
SET PASSWORD = PASSWORD('root');
flush privileges
 
开放访问权限
 

[root@VM_199_194_centos bin]# mysql -uroot -proot


MySQL [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;


MySQL [(none)]>  flush privileges;

 
 

posted on 2016-07-07 01:34  adamas  阅读(456)  评论(0编辑  收藏  举报

导航