2.二进制安装mysql
Posted coisini
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2.二进制安装mysql相关的知识,希望对你有一定的参考价值。
一、安装二进制mysql数据库
1. 下载mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
- tar -xf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz (解压压缩包)
- mv mysql-8.0.18-linux-glibc2.12-x86_64 /usr/local/mysql (移动文件夹)
- groupadd mysql -r && useradd -r -g mysql -M mysql -s /bin/false (给权限)
- rpm -e mariadb-libs –nodeps (卸载mariadb)
- mkdir /usr/local/mysql/data (创建文件夹)
- cat > /etc/my.cnf <<EOF (写入配置文件)
- [mysqld]
- basedir=/usr/local/mysql/
- datadir=/usr/local/mysql/data
- pid-file=/usr/local/mysql/data/mysql.pid
- socket=/tmp/mysql.sock
- log-error=/usr/local/mysql/data/mysql.err
- EOF
- mysql --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data(初始化数据库)
- cp -p /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld (复制启动脚本)
- /etc/init.d/mysqld start (启动数据库)
- b=`grep password /usr/local/mysql/data/mysql.err | awk -F \'root@localhost: \' \'{print $2}\'` (过滤密码)
- mysql -uroot -p${b} -e \'alter user root@localhost identified by"123.Com"\' --connect-expired-password(更改密码)
以上是关于2.二进制安装mysql的主要内容,如果未能解决你的问题,请参考以下文章