linux环境下 yum安装mysql

#1.连接本地VM虚拟机,或者连接阿里云
用finalshell连接本地虚拟机:ip addr 获得本地IP地址 ens33: inet 192.168.3.72/24 进行连接 (final了shell更方便而已)

	(1)检查是否安装过mysql服务,	

	rpm -qa | grep mysqlyum list installed | grep mysql

	(2)删除安装的mysql

	yum -y remove mysql-libs.x86_64

#2.安装wget
yum -y install wget

#3.安装MySQL的yum源 :

 (1)wget-i-c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

 (2)yum -y install mysql57-community-release-el7-10.noarch.rpm
#4安装MySQL
yum -y install mysql-community-server

----------------------------------------等等等--------------------------------------------------

#配置阶段

1:启动mysql服务
       systemctl start mysqld.service
2:停止mysql服务
		service mysqld stop/  systemctl start mysqld.service
3:重启
	service mysqld restart
2:查看服务状态
  systemctl status mysqld.service


● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-07-31 15:17:01 CST; 18s ago
 Docs: man:mysqld(8)
       http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 10273 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 10256 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 10278 (mysqld)
   CGroup: /system.slice/mysqld.service
       └─10278 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Jul 31 15:17:00 yu540241 systemd[1]: Starting MySQL Server...
Jul 31 15:17:01 yu540241 systemd[1]: Started MySQL Server.

#不过现在我们还是进不去,因为我们没有密码啊
[root@yu540241 /]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

#查看本地root密码
grep ‘temporary password’ /var/log/mysqld.log

[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2019-07-31T08:36:58.369118Z 1 [Note] A temporary password is generated for root@localhost:** W1nsd#bBD+HC**(这就是密码)

#下面我们选择一个自己喜欢的密码吧
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘Yu22333’;

我的密码就是 : Yu22333 了

你可能感兴趣的:(linux,MySQL)