1.解压mysql到指定目录(/usr/local/)
tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
2.将文件夹名字(mysql-5.7.25-linux-glibc2.12-x86_64)改成mysql
cd /usr/local
---------------进入目录
mv mysql-5.7.25-linux-glibc2.12-x86_64 mysql
3.在mysql文件夹里 创建data文件夹,并赋权限
cd mysql
mkdir data
---------------- //创建文件夹
chown -R mysql .
-------------- //改变文件拥有者 R是递归当前目录
chgrp -R mysql .
---------------- //改变所属用户组 点代表当前目录
chown -R mysql:mysql data
------------------//设置data文件夹权限
chown -R mysql.mysql /usr/local/mysql/
---------------//设置mysql文件夹权限
4.基本配置
cp support-files/mysql.server /etc/init.d/mysql
--------------//开机启动脚本
vim support-files/my_default.cnf
-----------在support-files创建my_default.conf
代码内容:
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8
log-error = /usr/local/mysql/data/mysqld.log
pid-file = /usr/local/mysql/data/mysqld.pid`
cp support-files/my_default.cnf /etc/my.cnf
--------------//拷贝配置文件
./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
---------- //初始化数据库
cat /root/.mysql_secret
------------------//查看初始密码
service mysql start
----------------------------//启动服务
./bin/mysql -u root -p
--------//登录mysql
这样就安装好了