MySQL5.7.24 安装

官网地址 https://dev.mysql.com/downloads/mysql/

 

 

 
1. 安装依赖  yum install -y cmake make gcc gcc-c++ libaio ncurses ncurses-devel

 cd /usr/local/src

 wget  https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz(用这个,后续的步骤都一样)

解压     
tar
-zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

将解压的复制到 /usr/local/mysql 目录
cp -r mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

2、添加系统mysql组和mysql用户
添加系统mysql组 groupadd mysql
添加mysql用户 useradd
-r -g mysql mysql (添加完成后可用id mysql查看)

3、安装数据库 切到mysql目录 cd /usr/local/mysql
修改当前目录拥有者为mysql用户
chown
-R mysql:mysql ./

安装数据库 bin
/mysqld --initialize --user=mysql --basedir=/usr/local/mysql5724 --datadir=/usr/local/mysql5724/data
生成了临时密码 (看到有的报这个错 bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 
解决方法:yum install
-y libaio //安装后在初始化就OK了)

执行以下命令创建RSA private key

bin
/mysql_ssl_rsa_setup --datadir=/usr/local/mysql5724/data
 
修改当前目录拥有者为mysql用户 chown
-R mysql:mysql ./

修改当前data目录拥有者为mysql用户 chown
-R mysql:mysql data


4、配置my.cnf vim /etc/my.cnf (直接把下面内容复制上就行)
[mysqld]
character_set_server
=utf8
init_connect
='SET NAMES utf8'
basedir
=/usr/local/mysql5724
datadir
=/usr/local/mysql5724/data
socket
=/tmp/mysql.sock

#不区分大小写 (sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 这个简单来说就是sql语句是否严格)
lower_case_table_names = 1 log-error=/var/log/mysqld.log pid-file=/usr/local/mysql5724/data/mysqld.pid

添加开机启动 cp
/usr/local/mysql5724/support-files/mysql.server /etc/init.d/mysqld

修改 vim
/etc/init.d/mysqld 添加路径 在46行
basedir
=/usr/local/mysql5724 datadir=/usr/local/mysql5724/data


5、启动mysql service mysqld start

 加入开机起动    chkconfig --add mysqld  
6、登录修改密码 mysql -uroot -p 上面初始化时的密码 如果出现错误 需要添加软连接 ln -s /usr/local/mysql5724/bin/mysql /usr/bin 第一件事先修改密码 alter user 'root'@'localhost' identified by 'root'; flush privileges; #刷新权限 GRANT ALL PRIVILEGES ON *.* TO 'root1'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; #授权新用户

 

 

 

posted @ 2019-01-10 15:21  裸奔的小鸵鸟  阅读(422)  评论(0编辑  收藏  举报