CentOS7下MySQL5.7的安装

2022-12-01 08:55:56 浏览数 (1)

1、下载MySQL 安装包:

  • wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
  • yum -y localinstall mysql57-community-release-el7-11.noarch.rpm

2、在线安装MySQL

  • yum -y install mysql-community-server

3、启动mysql 服务

  • systemctl start mysqld

4、设置开机启动

  • systemctl enable mysqld
  • systemctl daemon-reload

5、修改root登录密码

  • mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。vim /var/log/mysqld.log
代码语言:javascript复制
2020-07-21T06:45:28.566414Z 1 [Note] A temporary password is generated for root@localhost: TxUa>Lh>D7B!
  • 记住初始密码,修改root 密码:mysql -u root -p
  • ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'
  • #设置远程登录GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新密码' WITH GRANT OPTION;

6、退出

  • exit

7、配置mysql默认编码为utf-8

  • vim /etc/my.cnf添加如下代码
代码语言:javascript复制
character_set_server=utf8
init_connect='SET NAMES utf8'
  • systemctl restart mysqld重启mysql
  • 进入mysql使用show variables like '%character%';查看编码格式!

0 人点赞