Linux 安装mysql 数据库
一下为mysql 安装教程
Using username"root".
Last login: Tue Oct8 09:30:34 from 113.98.245.93Welcome to Alibaba Cloud Elastic Compute Service![root@lwh~]# yum list installed mysql*已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
错误:没有匹配的软件包可以列出
[root@lwh~]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
已加载插件:fastestmirror, langpacks
无法打开 mysql57-community-release-el7-8.noarch.rpm ,跳过。
无须任何处理
[root@lwh~]# cd /root
[root@lwh~]#wget /mysql57-community-release-el7-8.noarch. rpm
---10-08 09:40:16-- /mysql57-community-release-el7-8.n oarch.rpm
正在解析主机 ()... 104.127.195.16正在连接 ()|104.127.195.16|:80... 已连接。
已发出 HTTP 请求,正在等待回应...200OK
长度:9116 (8.9K) [application/x-redhat-package-manager]
正在保存至: “mysql57-community-release-el7-8.noarch.rpm”100%[======================================>] 9,116 --.-K/s 用时 0s-10-08 09:40:16 (118 MB/s) - 已保存 “mysql57-community-release-el7-8.noarch. rpm” [9116/9116])
[root@lwh~]#rpm -ivh mysql57-community-release-el7-8.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...1:mysql57-community-release-el7-8 ################################# [100%]
[root@lwh~]#cd /etc/yum.repos.d/[root@lwh yum.repos.d]# ls
CentOS-Base.repo CentOS-Media.repo mysql-community.repo
CentOS-CR.repo CentOS-Sources.repo mysql-community-source.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
CentOS-fasttrack.repo epel.repo
[root@lwh yum.repos.d]# yum install mysql-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
mysql-connectors-community | 2.5 kB 00:00mysql-tools-community | 2.5 kB 00:00mysql57-community | 2.5 kB 00:00正在解决依赖关系-->正在检查事务---> 软件包 mysql-community-server.x86_64.0.5.7.27-1.el7 将被 安装--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.7.27-1.el7,它被软件包 m ysql-community-server-5.7.27-1.el7.x86_64 需要--> 正在处理依赖关系 mysql-community-client(x86-64) >= 5.7.9,它被软件包 mysql-c ommunity-server-5.7.27-1.el7.x86_64 需要-->正在检查事务---> 软件包 mysql-community-client.x86_64.0.5.7.27-1.el7 将被 安装--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 5.7.9,它被软件包 mysql-com munity-client-5.7.27-1.el7.x86_64 需要---> 软件包 mysql-community-common.x86_64.0.5.7.27-1.el7 将被 安装-->正在检查事务---> 软件包 mysql-community-libs.x86_64.0.5.7.27-1.el7 将被 安装-->解决依赖关系完成
依赖关系解决================================================================================Package 架构 版本 源 大小================================================================================正在安装:
mysql-community-server x86_64 5.7.27-1.el7 mysql57-community 165M
为依赖而安装:
mysql-community-client x86_64 5.7.27-1.el7 mysql57-community 24M
mysql-community-common x86_64 5.7.27-1.el7 mysql57-community 275k
mysql-community-libs x86_64 5.7.27-1.el7 mysql57-community 2.2M
事务概要================================================================================安装1 软件包 (+3依赖软件包)
总下载量:192M
安装大小:865M
Isthis ok [y/d/N]: y
Downloading packages:
(1/4): mysql-community-common-5.7.27-1.el7.x86_64.rpm | 275 kB 00:00(2/4): mysql-community-libs-5.7.27-1.el7.x86_64.rpm | 2.2 MB 00:00(3/4): mysql-community-client-5.7.27-1.el7.x86_64.rpm | 24 MB 00:02(4/4): mysql-community-server-5.7.27-1.el7.x86_64.rpm | 165 MB 00:00:47
------------------------------------------------------------------------------------------------------------------------------------------------------------------------总计4.0 MB/s | 192 MB 00:00:48Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。** 发现 1 个已存在的 RPM 数据库问题, 'yum check'输出如下:
python-requests-2.6.0-5.el7.noarch 有缺少的需求 python-urllib3 >= ('0', '1.10.2', '1')
正在安装 : mysql-community-common-5.7.27-1.el7.x86_64 1/4正在安装 : mysql-community-libs-5.7.27-1.el7.x86_64 2/4正在安装 : mysql-community-client-5.7.27-1.el7.x86_64 3/4正在安装 : mysql-community-server-5.7.27-1.el7.x86_64 4/4验证中 : mysql-community-client-5.7.27-1.el7.x86_64 1/4验证中 : mysql-community-common-5.7.27-1.el7.x86_64 2/4验证中 : mysql-community-libs-5.7.27-1.el7.x86_64 3/4验证中 : mysql-community-server-5.7.27-1.el7.x86_64 4/4已安装:
mysql-community-server.x86_64 0:5.7.27-1.el7
作为依赖被安装:
mysql-community-client.x86_64 0:5.7.27-1.el7 mysql-community-common.x86_64 0:5.7.27-1.el7 mysql-community-libs.x86_64 0:5.7.27-1.el7
完毕!
[root@lwh yum.repos.d]# mysql-V
mysql Ver14.14 Distrib 5.7.27, forLinux (x86_64) using EditLine wrapper
[root@lwh yum.repos.d]#service mysqld start
Redirecting to/bin/systemctl start mysqld.service
[root@lwh yum.repos.d]# service mysqld status
Redirecting to/bin/systemctl status mysqld.service
● mysqld.service-MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor prese t: disabled)
Active: active (running) since 二-10-08 09:53:29CST; 12s ago
Docs: man:mysqld(8)
/doc/refman/en/using-systemd.html
Process: 1397 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysql d/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process:1291 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID:1400(mysqld)
Tasks:27CGroup:/system.slice/mysqld.service
└─1400 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...
10月08 09:53:21 lwh systemd[1]: Starting MySQL Server...
10月08 09:53:29 lwh systemd[1]: Started MySQL Server.
[root@lwh yum.repos.d]# grep"password" /var/log/mysqld.log-09-27T02:54:37.514492Z 1 [Note] A temporary password is generated for root@ localhost: dM/+;gxtx5u&
-09-27T02:56:51.941440Z 2 [Note] Access denied for user 'root'@'localhost'( using password: YES)-09-27T07:13:29.544662Z 0 [Note] Shutting down plugin 'validate_password'
-09-27T07:13:30.919751Z 0 [Note] Shutting down plugin 'sha256_password'
-09-27T07:13:30.919754Z 0 [Note] Shutting down plugin 'mysql_native_passwor '
-09-27T07:14:15.493803Z 0 [Note] Shutting down plugin 'validate_password'
-09-27T07:14:16.901327Z 0 [Note] Shutting down plugin 'sha256_password'
-09-27T07:14:16.901330Z 0 [Note] Shutting down plugin 'mysql_native_passwor '
-09-27T07:17:53.235441Z 0 [Note] Shutting down plugin 'validate_password'
-09-27T07:17:54.481004Z 0 [Note] Shutting down plugin 'sha256_password'
-09-27T07:17:54.481008Z 0 [Note] Shutting down plugin 'mysql_native_passwor '
-09-27T07:19:43.334368Z 2 [Note] Access denied for user 'root'@'localhost'( using password: NO)-09-27T07:24:01.586076Z 3 [Note] Access denied for user 'root'@'localhost'( using password: YES)-09-27T07:38:25.108093Z 0 [Note] Shutting down plugin 'validate_password'
-09-27T07:38:26.832129Z 0 [Note] Shutting down plugin 'sha256_password'
-09-27T07:38:26.832133Z 0 [Note] Shutting down plugin 'mysql_native_passwor '
-09-27T07:44:06.256534Z 3 [Note] Access denied for user 'root'@'localhost'( using password: NO)-09-27T08:20:25.906079Z 2 [Warning] Plugin validate_password reported: 'Effe ctive value of validate_password_length is changed. New value is 4'
-09-29T01:17:21.691602Z 4 [Note] Access denied for user 'root'@'localhost'( using password: YES)-09-29T02:57:47.686866Z 0 [Note] Shutting down plugin 'validate_password'
-09-29T02:57:49.286496Z 0 [Note] Shutting down plugin 'sha256_password'
-09-29T02:57:49.286499Z 0 [Note] Shutting down plugin 'mysql_native_passwor '
-10-08T01:53:25.842666Z 1 [Note] A temporary password is generated for root@ localhost: jN2+I2R8KiIk
[root@lwh yum.repos.d]# mysql-uroot -p'jN2+I2R8KiIk'mysql: [Warning] Using a password on the command lineinterfacecan be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is2Server version:5.7.27Copyright (c)2000, , Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type'help;' or '\h' for help. Type '\c'to clear the current input statement.
mysql>mysql> SET PASSWORD = PASSWORD('passw0rd');
ERROR1819(HY000): Your password does not satisfy the current policy requirements
mysql> set global validate_password_policy=0;
Query OK,0 rows affected (0.00sec)
mysql> SET PASSWORD = PASSWORD('passw0rd'); --设定mysql密码
Query OK,0 rows affected, 1 warning (0.00sec)
mysql>ALTER USER 'root'@'localhost'PASSWORD EXPIRE NEVER; --设定用户下的密码永久生效,不过期
Query OK,0 rows affected (0.00sec)
mysql>flush privileges; --以上命令即时生效
Query OK,0 rows affected (0.00sec)
mysql>grant all privileges on *.* to root@"%" identified by "passw0rd"; --允许其他任意机主登录mysql数据库
Query OK,0 rows affected, 1 warning (0.00sec)
mysql> grant all privileges on *.* to root@"localhost" identified by "passw0rd"; --允许其他任意主机登录mysql数据库Query OK, 0 rows affected, 1 warning (0.00sec)