- 删除旧的mysql文件 (find / -name mysql)
- 删除mysql安装文件
- rpm -qa|grep mysql
- rpm -e --nodeps xxxx.86_64(上一步查询到的列表)
- 删除自带的mariadb
- rpm -qa|grep mariadb
- rpm -e --nodeps xxxx.86_64(上一步查询到的列表)
- 清除旧文件后开始安装
- groupadd mysql
- useradd -r -g mysql mysql
- 进入mysql(解压后文件夹重命名为mysql)
- chown -R mysql.mysql /usr/local/mysql
- mkdir data
- 进入 support-files 创建 my_default.cnf 配置文件,内容如下:
[mysqld] basedir =/usr/local/mysql datadir = /usr/local/mysql/data port = 3306 socket = /tmp/mysql.sock character-set-server=utf8 log-error = /usr/local/mysql-5.7.28/data/mysqld.log pid-file = /usr/local/mysql-5.7.28/data/mysqld.pid
- cp my_default.cnf /etc/my.cnf
- ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 初始化mysql
- 查看/mysql/data/mysqld.log 获取初始密码
- cp support-files/mysql.server /etc/init.d/mysql 复制执行文件到自启动
- service mysql start 启动mysql
- ./bin/mysql -u root -p 登录
- set password=password('123456'); 重置密码
- grant all privileges on *.* to root@'%' identified by '123456'; 授权
- flush privileges;
- use mysql;
- update user set host='%' where user = 'root'; 添加远程访问
- flush privileges;
- service mysql restart 重启
- 远程登录