mysql5.7 百度云盘 密码:gmxd
安装
1.创建/usr/share/java目录
mkdir -p /usr/share/java
2.将解压后的mysql-connector-java-5.1.47.jar放入/usr/share/java目录下,并更改名称为mysql-connector-java.jar
3.卸载mariadb
查看版本
rpm -qa|grep mariadb
卸载,注意与上面版本一致
rpm -e --nodeps mariadb-libs-5.5.64-1.el7_5.x86_64
4.创建 /opt/mysql 目录,并将解压mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar后的文件放入该路径
5.依次执行以下命令
rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm
配置
1.初始化
# 初始化mysql ,root代表当前用户
mysqld --initialize --user=root
2.开启服务
systemctl start mysqld.service
如果出现错误,请看底部错误解决方法。
3.登录mysql
mysql -uroot –p
如果不能登录,则设置免密登录。
先关闭sql服务
systemctl stop mysqld.service
vi /etc/my.cnf
并在末尾加上
skip-grant-tables
保存退出后,再次开启sql服务
systemctl start mysqld.service
输入 mysql,则成功免密进入。
4.重置root密码
mysql> use mysql
mysql> update user set authentication_string=password('123456') where user='root';
记得去 /etc/my.cnf,注释免密设置。
先重启服务,然后就可以正常登录mysql
mysql -uroot -p123456
错误
- 如下
warning: mysql-community-libs-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.26-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-5.7.26-1.el7.x86_64
检查是否卸载mariadb,没有则从安装的第三步重新开始。
- 如下
error: Failed dependencies:
/usr/bin/perl is needed by mysql-community-server-5.7.26-1.el7.x86_64
执行以下命令,安装完成即可:
yum install -y perl-Module-Install.noarch
- 如下
error: Failed dependencies:
net-tools is needed by mysql-community-server-5.7.26-1.el7.x86_64
执行以下命令,安装完成即可:
yum install net-tools
- 开启mysql服务,出现
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
执行删除之后
rm -rf /var/lib/mysql
并执行,即可。
systemctl start mysqld.service
5.使用sql命令时,出现如下错误:
You must reset your password using ALTER USER statement before executing this statement.
请看 这里
=================================================================
个人博客
Github
个人公众号:Flutter小同学
个人网站