当前位置:网站首页>Linux环境下MySQL的安装过程
Linux环境下MySQL的安装过程
2022-06-21 08:26:00 【油条生煎】
文章目录
环境
- 阿里云 Linux 服务器:CentOS 7.6 64位
检测系统是否自带安装 MySQL
rpm -qa | grep mysql
如果你系统有安装,那可以选择进行卸载:
rpm -e mysql # 普通删除模式
rpm -e --nodeps mysql # 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
安装 MySQL
接下来我们在 Centos7 系统下使用 yum 命令安装 MySQL,需要注意的是 CentOS 7 版本中 MySQL数据库已从默认的程序列表中移除,所以在安装前我们需要先去官网下载 Yum 资源包,下载地址为:https://dev.mysql.com/downloads/repo/yum/
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
权限设置:
chown mysql:mysql -R /var/lib/mysql
初始化 MySQL:
mysqld --initialize
启动 MySQL:
systemctl start mysqld
查看 MySQL 运行状态:
systemctl status mysqld
验证 MySQL 安装
在成功安装 MySQL 后,一些基础表会表初始化,在服务器启动后,你可以通过简单的测试来验证 MySQL 是否工作正常。
使用 mysqladmin 工具来获取服务器状态:
使用 mysqladmin 命令来检查服务器的版本, 在 linux 上该二进制文件位于 /usr/bin 目录,在 Windows 上该二进制文件位于 C:\mysql\bin 。
mysqladmin --version
linux上该命令将输出以下结果,该结果基于你的系统信息:
mysqladmin Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386
如果以上命令执行后未输出任何信息,说明你的Mysql未安装成功。
使用 MySQL Client 执行简单的 SQL 命令
你可以在 MySQL Client(MySQL 客户端)使用 MySQL 命令连接到 MySQL 服务器上,默认情况下 MySQL 服务器的登录密码为空,所以本实例不需要输入密码。
命令如下:
mysql
以上命令执行后会输出 mysql> 提示符,这说明你已经成功连接到 MySQL 服务器上,你可以在 mysql> 提示符执行 SQL 命令:
mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.13 sec)
MySQL 安装后需要做的
MySQL 安装成功后,默认的 root 用户密码为空,你可以使用以下命令来创建 root 用户的密码:
mysqladmin -u root password "new_password";
现在你可以通过以下命令来连接到Mysql服务器:
mysql -u root -p
Enter password:*******
**注意:**在输入密码时,密码是不会显示了,你正确输入即可。
阿里云 MySQL 设置允许远程连接
本地登入 mysql,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,将"localhost"改为 “%”
flush privileges 是为了将权限更新操作刷新到内存中,而不用下次启动时生效。
mysql> use mysql;
mysql> select user, host from user;
mysql> update user set host = "%" where user='root' and host='localhost';
mysql> select user, host from user;
mysql> flush privileges;
边栏推荐
- Higher order functions in kotlin (first-class citizens)
- Unity . Net framework
- Global and Chinese market for packed gas chromatographic columns 2022-2028: Research Report on technology, participants, trends, market size and share
- Diary (C language summary)
- 5 minutes to understand MySQL - row to column
- 给两个字符串s和t,判断t是否为s的重新排列后组成的单词
- 给定一个m*n的二维列表,查找一个数是否存在
- PHP类与对象详细介绍
- 解密FTP
- 积分签到任务设置的要求,积分商城搭建过程中常见的问题
猜你喜欢

5分钟搞懂MySQL - 行转列

Tsinghua University | van: visual attention network

解密FTP

Linux Installation of Damon database /dm8 (with client tool installation full version)

2022-2028 global after sales spark plug industry research and trend analysis report

使用Lua+Redis+OpenResty实现电商首页并发优化

Use lua+redis+openresty to realize concurrent optimization of e-commerce Homepage

2022-2028 global boom cylinder industry research and trend analysis report

What should I do if a white page appears during MySQL installation

Eureka的TimedSupervisorTask类(自动调节间隔的周期性任务)
随机推荐
Gql+nodejs+mysql database
Tidb and MySQL modify system variables / common statements (kill the process in process)
How to write attractive titles for short videos? Learn these tips to make your title more convincing
2022-2028 global hydrogen engine industry research and trend analysis report
面试经验---字节
CTF show WEB10
WordPress obtains category name and link through category ID
[DB written interview 220] how to back up control files in oracle? What are the ways to back up control files?
33 Jenkins modify plug-in source
(greedy) B. avoid local maximums
Give two strings S and T, and judge whether T is the word formed after rearrangement of S
Global and Chinese market for crankshaft position sensors 2022-2028: Research Report on technology, participants, trends, market size and share
Blue Bridge Cup: Candy
Images, graphics and Applications (II)
Antique typesetting (20 points) (test point 4)
Unity 5 自带的Mono也可以支持C# 6
安装MySQL出现白页面怎么办
2022-2028 global after sales spark plug industry research and trend analysis report
Joking Domain Driven Design (VI) -- Boundary context -- Design
Requirements for setting up points sign in tasks and common problems in the process of building points mall