cd /usr/local/src
mkdir mysql useradd mysql
下载wget https://repo.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
解压
tar zxvf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
移动并改名
mv mysql-5.7.33-linux-glibc2.12-x86_64 /usr/local/mysql
权限修改
chown -R mysql.mysql mysql/
解压后初始化
cd /usr/local/mysql
./bin/mysqld --initialize-insecure --user=mysql --basedir=/data/server/mysql --datadir=/data/server/mysql/data
推荐用初始化参数
--initialize-insecure
,表示不安全的初始化。这个参数来自于
--initialize
参数,在MySQL5.7版本中,在初始化成功后,会生成一个临时密码,相对比较麻烦,所以这里改为
--initialize-insecure
,初始化时将root用户的登录密码设置为空。
编辑配置文件vim /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
prompt=3306 [\\d]>
修改启动脚本
./support-files/mysql.server start
ps aux | grep mysql
ll
标签:初始化,--,安装,glibc,usr,mysql,initialize,local From: https://www.cnblogs.com/yuyongqi/p/17773349.html