Linux CentOS7 虚拟机安装mysql教程

2019-01-25  本文已影响10人  Marlon1993

a)下载mysql源安装包:

[root@localhost ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

可能会遇到如下错误:-bash: wget: 未找到命令  

[root@localhost ~]# yum -y install wget

[root@localhost ~]# yum -y install setup

[root@localhost ~]# yum -y install perl

只需要执行上面三行命令即可解决wget无法执行的错误

b)安装mysql源:

[root@localhost ~]# yum localinstall mysql57-community-release-el7-8.noarch.rpm

c)检测是否安装完成:

[root@localhost ~]# yum repolist enabled | grep "mysql.*-community.*"

d)安装mysql:

[root@localhost ~]# yum install mysql-community-server

e)设置开启启动mysql服务:

[root@localhost ~]# systemctl enable mysqld

h)修改系统默认密码:

下面这条命令我死活也没有出现密码,如果有感兴趣的可以试试:

[root@localhost ~]# grep 'A temporary password' /var/log/mysqld.log

我用的是下面的方式修改默认密码的:

[root@localhost usr]# mysql -u root -p

Enter password: 这里回车就行

mysql> USE mysql ;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

重点来了,下面的命令行就是修改root密码为自己的密码,请牢记,打死也不要告诉别人哦:

mysql> update mysql.user set authentication_string=password("****") where user="root";

mysql> flush privileges;    #立即生效   请不要quit,直接执行以下命令进行授权,用于远程访问

mysql> grant all privileges on *.* to "root"@"%%" identified by "marlon" with grant option;

mysql> flush privileges; 

然后本地就可以连接啦,恭喜你,Linux下mysql安装完成。

上一篇下一篇

猜你喜欢

热点阅读