Linux服务器---安装mysql

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
安装mysql
1、检测是否已安装mysql
      [root@localhost bin]#  rpm -qa | grep mysql
      mysql-libs-5.1.71-1.el6.i686
      [root@localhost bin]

2、安装mysql和mysql-server 
      [root@localhost bin]#  yum install -y mysql
      [root@localhost bin]#  yum install -y mysql-server

3、启动mysql,注意这里的服务名字是“mysqld”
      [root@localhost bin]#  service mysqld start
      shell-init: error retrieving current directory: getcwd: cannot access parent directories: 没有那个文件或目录
      chdir: error retrieving current directory: getcwd: cannot access parent directories: 没有那个文件或目录
      初始化 MySQL 数据库: Installing MySQL system tables...
      OK
      Filling help tables...
      OK                                                          [确定]
      正在启动 mysqld:                                          [确定]
      [root@localhost bin]# 

4、配置MySQL开机启动 
      [root@localhost bin]#  chkconfig mysqld on
      [root@localhost bin]#  chkconfig --list mysqld
      mysqld          0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
      [root@localhost bin]# 

5、设置root用户密码 ,设置密码的命令是“mysqladmin -u 用户名password 密码”
      [root@localhost bin]#  mysqladmin -u root password 543092   //密码是543092

6、修改密码,命令是“mysqladmin -u 用户名 -p password 新密码” 
      [root@localhost bin]#  mysqladmin -u root -p password 123456     //新密码123456
      Enter password:        //这里要求输入旧密码
      [root@localhost bin]# 

7、mysql配置文件“/etc/my.cnf” 
      [root@localhost bin]#  cat /etc/my.cnf  
      [mysqld]
       datadir=/var/lib/mysql             //数据库文件目录
      socket=/var/lib/mysql/mysql.sock     //socket文件

       user=mysql
      # Disabling symbolic-links is recommended to prevent assorted security risks
      symbolic-links=0


       [mysqld_safe]
      log-error=/var/log/mysqld.log      //日志文件
      pid-file=/var/run/mysqld/mysqld.pid     //进程pid文件



8、修改端口
1)mysql默认的端口是3306,可以使用netstat来查看
      [root@localhost bin]#  netstat -tunlp | grep mysqld
      tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4339/mysqld         
2)端口在配置文件中修改,打开配置文件,在后面追加一句话”port=xxx” 
      [root@localhost bin]#  gedit /etc/my.cnf
       port=3307       
3)重启myslqd服务,查看端口 
      [root@localhost bin]#  service mysqld restart
      shell-init: error retrieving current directory: getcwd: cannot access parent directories: 没有那个文件或目录
      chdir: error retrieving current directory: getcwd: cannot access parent directories: 没有那个文件或目录
      ^[[A停止 mysqld:                                          [确定]
      正在启动 mysqld:                                          [确定]
      [root@localhost bin]#  netstat -tunlp | grep mysqld
      tcp        0      0 0.0.0.0:3307                0.0.0.0:*                   LISTEN      4604/mysqld      
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
3天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
13 0
|
3天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
33 2
|
6天前
|
Linux 数据安全/隐私保护
Linux基础与服务器架构综合小实践
【4月更文挑战第9天】Linux基础与服务器架构综合小实践
1192 6
|
7天前
|
关系型数据库 MySQL 数据库
Docker安装MySQL
Docker安装MySQL
14 1
|
7天前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL 安装及连接
MySQL 安装及连接
25 0
|
6月前
|
Java 关系型数据库 MySQL
【Linux环境配置】Linux系统安装jdk1.8操作步骤
【Linux环境配置】Linux系统安装jdk1.8操作步骤
234 0
|
存储 Linux 数据安全/隐私保护
linux系统安装步骤
linux系统安装步骤
251 0
linux系统安装步骤
|
安全 关系型数据库 MySQL
Linux系统安装MySql步骤及截屏
原文出自【听云技术博客】:http://blog.tingyun.com/web/article/detail/1255 如下是我工作中的记录,介绍的是linux系统下使用官方编译好的二进制文件进行安装MySql的安装过程和安装截屏,这种安装方式速度快,安装步骤简单! 需要的朋友可以按照如下
4858 0
|
11天前
|
Web App开发 Linux 网络安全
工作中常用到的Linux命令
工作中常用到的Linux命令