CentOS7下yum安装MySQL

下载MySQL源安装包:

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

安装MySQL源:

yum install mysql57-community-release-el7-8.noarch.rpm

安装MySQL服务器:

yum install mysql-community-server

安装MySQL客户端(安装server时默认会安装client):

yum install mysql-community-client

启动MySQL:

systemctl start mysqld

Server安装完成之后,在/var/log/mysqld.log文件中存在root的一个默认密码,查看:

grep ‘temporary password’ /var/log/mysqld.log

[Note] A temporary password is generated for root@localhost: _Jd6hrbFj::U

使用此密码登录MySQL:

mysql -uroot -p_Jd6hrbFj::U

修改密码,首先关闭密码策略

vi /etc/my.cnf

[mysqld]下加入:validate_password = off

重启MySQL:

systemctl restart mysqld

连接MySQL并修改密码:

mysql -uroot -p_Jd6hrbFj::U

>set password for ‘root’@’localhost’=password(‘123456’);

允许远程用户登录:

mysql -uroot -p123456

>GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;

开放3306端口:

firewall-cmd –zone=public –add-port=3306/tcp –permanent
firewall-cmd –reload

修改默认编码:

vi /etc/my.cnf

[mysqld]下加入

character_set_server=utf8

init_connect=’SET NAMES utf8′

设置开机启动:

systemctl enable mysqld

systemctl daemon-reload

IT文库 » CentOS7下yum安装MySQL
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址