①上传更新包
tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
③重命名
mv /usr/local/mysql-5.7.27-linux-glibc2.12-x86_64 /usr/local/mysql
④新建data目录
mkdir /usr/local/mysql/data
⑤新建mysql用户和mysql用户组
mysql用户命令:
groupadd mysql
mysql用户组命令:
useradd mysql -g mysql
⑥将/usr/local/mysql的所有者及所属组改为mysql
chown -R mysql.mysql /usr/local/mysql
⑦ 配置
/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
⑧配置/etc/my.cnf
[mysqld]
#Mysql服务的唯一编号 每个mysql服务Id需唯一
server-id = 1
#mysql数据文件所在位置
datadir=/usr/local/mysql/data
#mysql安装根目录
basedir=/usr/local/mysql
#设置socke文件所在目录
socket=/tmp/mysql.sock
user=mysql
#服务端口号 默认3306
port=3306
character-set-server=utf8
# 取消密码验证
skip-grant-tables=1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# skip-grant-tables
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
⑧开启服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
⑨开机自启
chkconfig mysql on
⑩启动Mysql服务
service mysql start
修改密码:
/usr/local/mysql/bin/mysql -u root -p
随意写入密码
使用mysql表:
use mysql;
修改命令:
update user set authentication_string=password('你的密码') where user='root';
刷新配置:
flush privileges;
退出:
exit;
修改my.cnf:重启
service mysql restart
再次登录:
/usr/local/mysql/bin/mysql -u root -p
再次修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '修改后的密码';
再次退出:
exit;
再次登录:
/usr/local/mysql/bin/mysql -u root -p输入密码后
use mysql;
update user set host='%' where user = 'root';
刷新配置:
flush privileges;
退出:
exit;
最后使用mysql客户端连接验证