加入收藏 | 设为首页 | 会员中心 | 我要投稿 台州站长网 (https://www.0576zz.cn/)- 边缘计算、中间件、数据处理、数据分析、智能存储!
当前位置: 首页 > 综合聚焦 > CentOS > 正文

Linux( CentOs7 )下安装MySQL

发布时间:2020-09-01 20:16:20 所属栏目:CentOS 来源:互联网
导读:1.下载 $ wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 2.安装MySQL源 ,如果没有yum 移步安装https://segmentfault.com/n/1330000014274523 $ yum localinstall mysql57-community-release-el7-8.noarch.rpm 3.检查MySQL源是

1.下载

$ wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2.安装MySQL源 ,如果没有yum 移步安装

$ yum localinstall mysql57-community-release-el7-8.noarch.rpm

3.检查MySQL源是否安装成功

$ yum repolist enabled | grep "mysql.*-community.*"

4.安装MySQL

$ yum install mysql-community-server 

5.启动MySQL服务

$ systemctl start mysqld

6.查看MySQL的启动状态

$ systemctl status mysqld

7.设置开机启动

$ systemctl enable mysqld
$ systemctl daemon-reload

8.获得root默认密码

$ grep 'temporary password' /var/log/mysqld.log

9.修改root密码(设置密码必须大小写字母+数字+特殊字符)

$ mysqladmin -u root -p password "Mshu1995." 
Enter password: 【输入默认密码】 

10.登陆root

$ mysql -uroot -p
Enter password: 【新密码】

11.退出MySQL

$ exit

12.设置用户(mshu)允许远程连接

$ GRANT ALL PRIVILEGES ON *.* TO 'mshu'@'%' IDENTIFIED BY 'Mshu1995.' WITH GRANT OPTION;
$ flush privileges;

13.想要远程连接还需关闭防火墙(仅适用于CentOs7)

1.$ firewall-cmd --state   //查看防火墙状态
     ---run             //开启状态
   ---not run          //关闭状态
2. $ systemctl stop firewalld.service   //关闭防火墙
 $ systemctl disable firewalld.service  //禁止firewall开机启动

14.设置编码

1.修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
 [mysqld]
 character_set_server=utf8
 init_connect='SET NAMES utf8'
2.重新启动mysql服务
 $ service mysqld restart
3. 查看数据库默认编码
 $ show variables like '%character%';

(编辑:台州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读