美文网首页
之AWS mysql下载和配置

之AWS mysql下载和配置

作者: o惜乐o | 来源:发表于2018-06-04 16:12 被阅读0次

    本文介绍了在AWS中mysql的下载以及相关的配置

    一.通过yum下载mysql的相关文件.

    1.进入etc文件目录.
    cd /etc
    
    2.下载mysql.
    sudo yum install mysql
    

    显示以下信息,表示下载并安装成功.

    Installed:
      mysql.noarch 0:5.5-1.6.amzn1                                                  
    Dependency Installed:
      mysql-config.x86_64 0:5.5.59-1.20.amzn1   mysql55.x86_64 0:5.5.59-1.20.amzn1  
      mysql55-libs.x86_64 0:5.5.59-1.20.amzn1  
    Complete!
    
    3.下载mysql-server.
    sudo yum install mysql-server
    

    显示以下信息,表示下载并安装成功.

    Installed:
      mysql-server.noarch 0:5.5-1.6.amzn1                                           
    Dependency Installed:
      mysql55-server.x86_64 0:5.5.59-1.20.amzn1                                     
      perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.11.amzn1                             
      perl-Compress-Raw-Zlib.x86_64 1:2.061-4.1.amzn1                               
      perl-DBD-MySQL55.x86_64 0:4.023-5.23.amzn1                                    
      perl-DBI.x86_64 0:1.627-4.8.amzn1                                             
      perl-Data-Dumper.x86_64 0:2.145-3.5.amzn1                                     
      perl-IO-Compress.noarch 0:2.061-2.12.amzn1                                    
      perl-Net-Daemon.noarch 0:0.48-5.5.amzn1                                       
      perl-PlRPC.noarch 0:0.2020-14.7.amzn1                                         
    Complete!
    
    4.下载mysql-devel.
    sudo yum install mysql-devel
    

    显示以下信息,表示下载并安装成功.

    Installed:
      mysql-devel.noarch 0:5.5-1.6.amzn1                                            
    Dependency Installed:
      keyutils-libs-devel.x86_64 0:1.5.8-3.12.amzn1                                 
      krb5-devel.x86_64 0:1.15.1-8.43.amzn1                                         
      libcom_err-devel.x86_64 0:1.42.12-4.40.amzn1                                  
      libkadm5.x86_64 0:1.15.1-8.43.amzn1                                           
      libselinux-devel.x86_64 0:2.1.10-3.22.amzn1                                   
      libsepol-devel.x86_64 0:2.1.7-3.12.amzn1                                      
      libverto-devel.x86_64 0:0.2.5-4.9.amzn1                                       
      mysql55-devel.x86_64 0:5.5.59-1.20.amzn1                                      
      openssl-devel.x86_64 1:1.0.2k-12.109.amzn1                                    
      zlib-devel.x86_64 0:1.2.8-7.18.amzn1                                          
    Dependency Updated:
      openssl.x86_64 1:1.0.2k-12.109.amzn1                                          
    Complete!
    

    二.配置mysql.

    1.进入mysql文件夹
    cd /var/lib/mysql
    
    2.将/var/lib路径下的mysql文件用户组设为mysql.
    sudo chgrp -R mysql /var/lib/mysql
    
    3.修改文件权限为可读可写可运行.
    sudo chmod -R 770 /var/lib/mysql
    
    4.开启mysql服务
    sudo service mysqld start
    

    显示mysql数据库正在初始化,之后开启mysql服务成功.

    Initializing MySQL database:  Installing MySQL system tables...
    ...
    ...
    ...
    Starting mysqld:                                           [  OK  ]
    
    5.设置mysql登录的账号和密码.
    /usr/bin/mysqladmin -u root password root
    

    以上第一个root为账号名,第二个root为密码

    6.连接mysql
    mysql -u root -p
    

    会显示:

    Enter password:
    

    输入刚刚设置的密码root.
    之后显示mysql欢迎提示和版本信息.

    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 5.5.59 MySQL Community Server (GPL)
    
    7.显示当前所有的数据库.
    mysql>show databases;
    

    显示

    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | test               |
    +--------------------+
    
    8.使用mysql.
    mysql>use mysql
    
    9.创建新账号和密码,授予远程登录的任意ip全部权限.
    grant all PRIVILEGES on *.* to root@'%' identified by 'root';
    

    解释:
    all PRIVILEGES指所有权限,也可以给予部分权限,如:
    select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等.
    第一个root为新的账号名.
    第二个root为新账号密码.
    *.*所有数据库的所有表.
    %为所有ip,此处可指定单个ip.
    某个ip用户例子:

    grant select,insert,update,delete,create,drop on test_database.* to baby@123.123.123.123 identified by '123456';
    

    表示:
    授予ip为123.123.123.123的用户baby分配可对test_database数据库的所有表进行select,insert,update,delete,create,drop操作的权限,并设定口令为123.

    三.连接mysql.

    Mac本可以通过MysqlWorkbench工具进行连接.
    输入账号root,密码root即可.


    CSDN

    Java开发之AWS mysql下载和配置

    相关文章

      网友评论

          本文标题:之AWS mysql下载和配置

          本文链接:https://www.haomeiwen.com/subject/fldesftx.html