标题

Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et dolore feugait

centos7.5安装mysql数据库

1、先创建/web/download目录,切换进去,然后下载mysql源
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2、下载好源后,安装源
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
3、开始安装mysql
yum -y install mysql-community-server
下载的东西比较多,需要等一会;
4、安装完成,启动mysql
systemctl start mysqld
5、设置开机启动
systemctl enable mysqld
systemctl daemon-reload
6、修改root本地登录密码
首先使用下面指令,获取默认root密码:
grep 'temporary password' /var/log/mysqld.log
如下图所示:




使用指令 mysql -u root -p ,然后输入上面图片中的密码登录数据库;

使用下面指令,修改root用户密码:

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘新的密码’;

备注:新密码必须包含大小写字母数字及字符,至少8位;

7、设置允许远程登录

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘这里输入密码’ WITH GRANT OPTION;

输入exit退出mysql;

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

输入vim /etc/my.cnf打开配置文件,在 [mysqld] 下面输入:

character_set_server=utf8

init_connect=’SET NAMES utf8′

编辑完后,保存退出;

接下来,重启mysql:

 systemctl restart mysqld

sdlqzql

发表评论