- 总体,下载mysql资源库,安装mysql资源库,yum中设置mysql版本,安装mysql
- https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html 官网网站
- https://dev.mysql.com/downloads/repo/yum/ 中选择centos版本官网网站
- 下载 wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm(我的centos 7 ,先点击下载,然后在不了谢谢处直接复制链接,下载80 好,因为你可以安装5.5 5.6 5.7 8 这三个版本)
- https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm centos 6
- 安装资源 yum localinstall mysql80-community-release-el7-3.noarch.rpm
- 查看 默认版本 yum repolist enabled | grep "mysql.*-community.*"
- 查看所有可用版本 yum repolist all | grep mysql
- 修改默认版本 vim /etc/yum.repos.d/mysql-community.repo (要安装的版本下设置 enabled=1 其他的版本 =0)
- 安装 yum install mysql-community-server
- systemctl start mysqld 启动
- 设置密码 关闭数据库服务 systemctl stop mysqld
- vim vim /etc/my.cnf 添加 这行 skip-grant-tables 跳过登录的验证 就是没有密码也能登上 在启动数据库服务
- mysql -uroot -p 登录数据库 提示密码时 直接回车键 use mysql
- update user set authentication_string =password('123456'),password_expired='N' where user='root'; 设置密码
- 注意mysql5。7 密码的字段的 authentication_string 以前的版本是 password
- flush privileges ; 刷新
- grant all privileges on *.* to 'root'@'%'identified by '123456' with grant option; 授权 所以用户可登录
- 刷新
- vim vim /etc/my.cnf 注释 这行 skip-grant-tables
- 重启 ok
- centos6安装默认5.1
- yum install mysql-server
service mysqld restart
mysql
show databases;
use mysql;
show tables;
desc mysql;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
delete from user where host!='%';
service mysqld restart 或者里面 flush privileges;
/etc/my.cnf 的[mysqld]下添加skip-name-resolve即可 - # 卸载
service mysqld stop
yum remove mysql mysql-* -y
rpm -qa | grep mysql
yum list installed | grep mysql - centos6 安装5.7
- wget https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm
- yum localinstall mysql80-community-release-el6-3.noarch.rpm -y
- 按照9操作
- yum install mysql-community-server
- 启动有时会报错
- cd /var/lib/mysql
rm -rf ./* - service mysqld restart
- service mysqld stop
- vim /etc/my.cnf 添加 skip-grant-tables 保存退出重启
- mysql -uroot
- use mysql
- grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
-
delete from user where host!='%';flush privileges;update user set password=password("123456") where user="root";
- quit
- 去掉 vim /etc/my.cnf skip-grant-tables
service mysqld restart - ok
- skip-name-resolve
- 5.7 安装不成功,5.6 一次安装成功,
- 5.6授权
- grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
- select HOST,user,authentication_string from user;
- update user set authentication_string =password('123456'),password_expired='N' where user='root';
- delete from user where host!='%';flush privileges;
- skip-name-resolve
- rpm -qa | grep mysql 查看是否安装
centos7 安装mysql 根据官网文档
最新推荐文章于 2024-06-06 15:20:31 发布