时间:2021-07-01 10:21:17 帮助过:11人阅读
rpm -qa | grep mysql rpm -qa | grep mariadb
若存在安装的软件包,请卸载
rpm -e --nodeps 软件包名
将/var/lib/mysql文件夹下的所有文件都删除干净
(一)将mysql5.7源码包上传到服务器中,并解压
tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz mkdir /home/mysql5.7 mv /home/mysql-5.7.24-linux-glibc2.12-x86_64/* /home/mysql5.7/
(二)添加系统用户
groupadd mysql useradd -r -g mysql mysql
(三)检查是否安装了 libaio
rpm -qa | grep libaio
注意:没有安装需要安装
(四)创建data目录
mkdir /home/mysql5.7/data
(五)安装mysql
/home/mysql5.7/bin/mysqld --user=mysql --basedir=/home/mysql5.7 --datadir=/home/mysql5.7/data --initialize
获得初始密码:;#Rg_k=we4kl
(六)修改启动配置文件
vim /home/mysql5.7/support-files/mysql.server
修改此部分内容:
if test -z "$basedir" then basedir=/home/mysql5.7 bindir=/home/mysql5.7/bin if test -z "$datadir" then datadir=/home/mysql5.7/data fi sbindir=/home/mysql5.7/bin libexecdir=/home/mysql5.7/bin else bindir="$basedir/bin" if test -z "$datadir" then datadir="$basedir/data" fi sbindir="$basedir/sbin" libexecdir="$basedir/libexec" fi
(七)复制相关启动文件,用于启动服务
cp /home/mysql5.7/support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld cp /home/mysql5.7/bin/my_print_defaults /usr/bin/
(八)修改启动脚本mysqld
vi /etc/init.d/mysqld
修改或添加此部分内容:
basedir=/home/mysql5.7/ datadir=/home/mysql5.7/data/ port=3306
(九)启动服务
service mysqld start
(十)进入mysql数据库,并重置密码
/home/mysql5.7/bin/mysql -uroot -p mysql> SET PASSWORD = PASSWORD(‘123456‘); Query OK, 0 rows affected, 1 warning (0.00 sec)
(十一)配置环境变量
vi /etc/profile
添加此部分内容到最后:
export PATH=$PATH:/home/mysql5.7/bin
刷新配置文件
source /etc/profile
(十二)开放远程连接权限
mysql -uroot -p mysql> use mysql mysql> update user set host=‘%‘ where user=‘root‘;
CentOS7安装MYSQL5.7
标签:inux ali eps color home export 添加 mysql5.7 exe