码迷,mamicode.com
首页 > 数据库 > 详细

linux安装mysql

时间:2021-02-06 11:41:02      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:hat   sql   rpm -ivh   密码   失败   连接mysql   版本   server   system   

1.下载mysql
https://dev.mysql.com/downloads/mysql/
操作系统选RedHat
依次下载四个安装包
mysql-community-common-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-5.7.33-1.el7.x86_64.rpm
mysql-community-server-5.7.33-1.el7.x86_64.rpm
mysql-community-client-5.7.33-1.el7.x86_64.rpm

2.移除已安装mysql,mariadb
centos7默认安装mariadb
rpm查看是否安装过mysql:
rpm -qa|grep -i mysql
rpm -qa|grep -i mariadb

移除安装过的mariadb和mysql
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

whereis mysql
find / -name mysql

rm -rf 删除
查看mysql是否启动:ps -ef |grep mysql

3.Xshell使用rz命令上传msyql文件并安装
下载地址:https://dev.mysql.com/downloads/mysql/
mysql-community-common-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-5.7.33-1.el7.x86_64.rpm
mysql-community-client-5.7.33-1.el7.x86_64.rpm
mysql-community-server-5.7.33-1.el7.x86_64.rpm
如下命令依次安装以上4个文件
rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rp

4.启动mysql
service mysqld start
systemctl start mysqld.service

5.连接msyql失败问题
mysql -uroot -p
登录失败:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
解决办法:
vim /etc/my.cnf
[mysqld]添加skip-grant-tables,这样再次登陆就不用输入密码,直接回车就进入数据库了。
重启服务:service mysqld restart
连接mysql:mysql -uroot -p
输入密码直接回车,进入mysql

6.设置数据库密码
use mysql;
show tables;
查看user表结构:desc user;
Host存的是允许访问的主机
User是登录名
authentication_string是登录密码,老版本用的字段是password
修改密码:update user set authentication_string=password(‘123456‘) where user=‘root‘;
退出mysql:quit;
重启服务:service mysqld restart

 

linux安装mysql

标签:hat   sql   rpm -ivh   密码   失败   连接mysql   版本   server   system   

原文地址:https://www.cnblogs.com/huangzhen22/p/14376995.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!