1.安装
https://www.cnblogs.com/lzhdonald/p/12511998.html
可以使用xftp上传到Linux中
2|0解压安装包并安装
使用tar命令解压
tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
安装新版mysql前,需将系统自带的mariadb-lib卸载
rpm -qa|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
为了避免出现权限问题,给mysql解压文件所在目录赋予最大权限
chmod -R 777 mysql
严格按照顺序安装:mysql-community-common-5.7.29-1.el7.x86_64.rpm、mysql-community-libs-5.7.29-1.el7.x86_64.rpm、mysql-community-client-5.7.29-1.el7.x86_64.rpm、mysql-community-server-5.7.29-1.el7.x86_64.rpm这四个包
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm
如果安装过程中出现这个错误就在后面添加 --force --nodeps,这可能是由于yum安装了旧版本的GPG keys造成的
3|0 配置数据库
vim /etc/my.cnf
添加这三行
skip-grant-tables character_set_server=utf8 init_connect='SET NAMES utf8'
skip-grant-tables:跳过登录验证
character_set_server=utf8:设置默认字符集UTF-8
init_connect='SET NAMES utf8':设置默认字符集UTF-8
4|0启动mysql 服务
设置开机启动
启动mysql
mysql
5|0设置密码和开启远程登录
5|1设置密码
先设置一个简单的密码
update mysql.user set authentication_string=password('123456') where user='root';
立即生效
flush privileges;
退出mysql并停止mysql服务
systemctl stop mysqld.service
编辑my.cnf配置文件将:skip-grant-tables这一行注释掉
重启mysql服务
systemctl start mysqld.service
再次登录mysql
mysql -uroot -p123456
如果输入其他命令出错,再重设密码
set password=password('123456');
2.
防火墙关闭
systemctl stop firewalld
或者关闭端口3306 数据库端口 ,10000服务端口??不成功
3.报错You must reset your password using ALTER USER statement before executing this statement.
mysql 5.7.14安装完后登陆报错,意思是密码过期
[root@mysql]# mysql -u root -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
解决办法:
1.在my.cnf mysqld 部分加入 skip-grant-tables 参数。
[mysqld]
skip-grant-tables
2.重启mysql数据库,然后登陆
[root@llmj-mysql-40-115 tools]# mysql -u root -p
Enter password: #这里直接回车,不需要密码即可登陆
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.14-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.=
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
3.查看mysql的用户状态
>select host,user,password_expired,account_locked from mysql.user;
+-----------+-----------+------------------+----------------+
| host | user | password_expired | account_locked |
+-----------+-----------+------------------+----------------+
| localhost | root | Y | N |
| localhost | mysql.sys | N | Y |
+-----------+-----------+------------------+----------------+
3 rows in set (0.00 sec)
password_expired :y说明密码已经过期,可以改成N,就是未过期
>update mysql.user set password_expired='N';
Query OK, 1 row affected (0.03 sec)
Rows matched: 2 Changed: 1 Warnings: 0
4.然后注释掉skip-grant-tables参数
重启mysql,用过期的密码就可以登陆了,登陆之后可以用下面的命令修改密码
>alter user user() identified by '123456';
Query OK, 0 rows affected (0.03 sec)
>flush privileges;
Query OK, 0 rows affected (0.03 sec)
其余参考ubuntu安装mysql5.7