职业类 > IT互联网 > 数据库 > centos7下安装mysql数据库
centos7下安装mysql数据库
落秋    2016-04-25 16:24:13     浏览()   回复()    点赞(0)   收藏(
添加收藏

1.jpg

MySQL是一个用于Web应用程序和服务器应用程序最流行的数据库管理系统。然而,MySQL再试是CentOS的默认数据库库,当前MariaDB已经成为默认的数据库系统进行提供。MariaDB是替代MySQL的另外一个数据库,如果你只需要一个数据库系统一般是足够的。看到我们在CentOS 7安装说明MariaDB指南。

如果你仍然喜欢MySQL,本指南将介绍如何安装、配置和管理上的Linode运行CentOS 7。 

下面我们在centos7上安装mysql数据库

  1. 下载更新远程程序仓库

    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
    sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum update

  2. 安装MySQL和往常一样启动服务。在安装过程中,会询问你是否愿意接受的结果。RPM文件的GPG验证。如果没有发生错误或不匹配,输入 y

    sudo yum install mysql-server
    sudo systemctl start mysqld

  3. MySQL将默认安装到本地(127.0.0.1)默认

  4. 加固我们的mysql服务

    sudo mysql_secure_installation,通过该命令,启动mysql安全配置,你会选择改变MySQL root密码,删除匿名用户帐户,禁用root登录在本地主机,并删除测试数据库。建议你对这些选择的答案是确定的

  5. 采用root登录

    mysql -u root -p

  6. 你可以查看命令帮助,通过 \h即可

    List of all MySQL commands:
    Note that all text commands must be first on line and end with ';'
    ?         (\?) Synonym for `help'.
    clear     (\c) Clear command.
    connect   (\r) Reconnect to the server. Optional arguments are db and host.
    delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
    edit      (\e) Edit command with $EDITOR.
    ego       (\G) Send command to mysql server, display result vertically.
    exit      (\q) Exit mysql. Same as quit.
    go        (\g) Send command to mysql server.
    help      (\h) Display this help.
    nopager   (\n) Disable pager, print to stdout.
    notee     (\t) Don't write into outfile.
    pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
    print     (\p) Print current command.
    prompt    (\R) Change your mysql prompt.
    quit      (\q) Quit mysql.
    rehash    (\#) Rebuild completion hash.
    source    (\.) Execute an SQL script file. Takes a file name as an argument.
    status    (\s) Get status information from the server.
    system    (\!) Execute a system shell command.
    tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
    use       (\u) Use another database. Takes database name as argument.
    charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
    warnings  (\W) Show warnings after every statement.
    nowarning (\w) Don't show warnings after every statement.

    For server side help, type 'help contents'


    mysql>

  7. 创建数据库和用户

    create database testdb;
    create user 'testuser'@'localhost' identified by 'password';
    grant all on testdb.* to 'testuser' identified by 'password';

注意:

允许无限制地访问一个公共IP不建议MySQL但你可以改变它的地址监听在/etc/ my.cnf修改绑定地址参数。如果你决定把MySQL你的公网IP,你应该实现的防火墙规则,只允许来自特定IP地址的连接。 


关注微信公众号优麦网,定时推送,福利互动精彩多多!

发表评论

分享者

相关分享