🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
#### 下载MySQL二进制包到/opt目录,开始安装 安装依赖 ```shell yum install libaio* libncurses* ``` 卸载mariadb ```shell yum remove mariadb-config mariadb-common mariadb-libs ``` 开始安装MySQL ```shell cd /opt && tar xzf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz mv mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/ groupadd mysql useradd -r -g mysql -s /bin/false mysql cd /usr/local ln -s mysql-5.7.18-linux-glibc2.5-x86_64 mysql chown -R mysql.mysql /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/ mkdir /data/mysql3306 chown -R mysql.mysql /data/mysql3306/ #上传my.cnf配置文件到/etc/下 cd /usr/local/mysql && bin/mysqld --initialize --user=mysql ``` 启动数据库 ```shell /etc/init.d/mysql.server start ``` 过滤临时密码 ```shell grep "root@localhost:" /data/mysql3306/error.log ``` 修改密码 ```shell # 5.7 alter user root@'localhost' identified by '123.com'; # 8.0 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxxxxxxx'; ```