centos 7 安装MySQL 5.7.23
centos 7 安装MySQL 5.7.23
1、 上传MySQL安装包到服务器
mysql-5.7.23-linux-glibc2.5-x86_64.tar.gz
2、 解压MySQL安装包
tar -zxvf
mysql-5.7.23-linux-glibc2.5-x86_64.tar.gz
3、 将解压的安装包移动到/usr/local下并命名为mysql-------(typically /usr/local/mysql)
mv mysql-5.7.23-linux-glibc2.5-x86_64
/usr/local/mysql
Directory |
Contents of Directory |
bin |
mysqld server, client and utility programs |
docs |
MySQL manual in Info format |
man |
Unix manual pages |
include |
Include (header) files |
lib |
Libraries |
share |
Error messages, dictionary, and SQL for database installation |
support-files |
Miscellaneous support files |
4、 添加用户组mysql
shell> groupadd mysql
5、 添加用户mysql
shell> useradd -r -g mysql -s /bin/false mysql
6、 创建目录
mkdir –p
/usr/local /mysql/data
7、 修改目录权限
Chown –R
mysql:mysql /usr/local /mysql
8、 初始化mysql数据库,并记录临时密码
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --defaults-file=/etc/my.cnf
9、 数据库加密
/usr/local/mysql/bin/mysql_ssl_rsa_setup
–datadir=/usr/local /mysql/data
10、 vi
/etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local
/mysql/data
socket=/tmp/mysql.sock
11、 cp
/usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改启动脚本参数
vi
/etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local
/mysql/data
12、 启动mysql
chkconfig
–add mysqld
/etc/init.d/mysqld
start
13、 登录
mysql –uroot
–p’临时密码’
14、 修改登录密码
set
password=password(‘mysql’);
15、 配置环境变量
export DATADIR=/usr/local /mysql/data
export BASEDIR=/usr/local/mysql
export PATH=$BASEDIR/bin:$PATH