zoukankan      html  css  js  c++  java
  • 在腾讯云centos7中安装mysql

    1. 程序下载

    先在mysql的官网下载rpm包

    2. 安装

    rpm包安装是有次序的,server要最后装,要不然会报错。可以依次装

    common

    libs

    devel

    client

    server

    在安装过程中会遇到报:

    xxx_2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64

    的错误,那直接把mariadb移除就行用命令

    1 yum -y remove mariadb-libs-1:5.5.44-2.el7.centos.x86_64
    View Code

    还会遇到这样的错误:

    error: Failed dependencies:
            libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.9-1.el6.x86_64

    表示缺少库,执行下列命令:

    1 yum  install    numactl
    View Code

    3. 设置

    先进行初始化

    #cd /usr/bin

    #mysqld --initialize --user=mysql

    #mysqld --initialize-insecure --user=mysql        --执行这句的时候可能有报错 先不用管

    启动数据库

    #service mysqld start

    可通过检查端口是否开启来查看MySQL是否正常启动:

    [root@xxx]#netstat -anp|grep 3306

    tcp        0     0 0.0.0.0:3306               0.0.0.0:*                   LISTEN      34693/mysqld

    修改密码等配置:

    #######启动mysql服务进程
    [root@typecodes ~]# systemctl start mysqld
    
    #######配置mysql(设置密码等)
    [root@typecodes ~]# mysql_secure_installation
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.
    
    Set root password? [Y/n] y                  [设置root用户密码]
    New password: 
    Re-enter new password: 
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] y                 [删除匿名用户]
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] y       [禁止root远程登录]
     ... Success!
    
    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] y          [删除test数据库]
     - Dropping test database...
    ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
     ... Failed!  Not critical, keep moving...
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y            [刷新权限]
     ... Success!
    
    
    
    
    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.
    
    Thanks for using MySQL!
    
    
    Cleaning up...

    进入数据库

    # mysql
    #mysql -u root -p
    #输入密码

     修改密码:

    >update mysql.user set authentication_string=password('root') where user='root'

    设置远程登陆:

    mysql>use mysql;
    mysql> update user set host='%' where user='root';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '填写root的密码' WITH GRANT OPTION;
    mysql> FLUSH PRIVILEGES;
    mysql>SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
    mysql>exit;
    #service mysqld restart

     本地客户端设置:

    下载hedisql,新建一个会话

    参考资料:

    1. http://blog.csdn.net/qq_35750399/article/details/65479837

    2.https://jingyan.baidu.com/album/93f9803f010d8fe0e56f555e.html?picindex=3

    3.http://blog.csdn.net/yoon0205/article/details/50605584

    4. https://www.jianshu.com/p/e723f3d68dc7

    5.http://blog.csdn.net/lxpbs8851/article/details/10895085 忘记密码怎么办

    6.https://stackoverflow.com/questions/16030453/redhat-mysql-failure 安装server出错的处理

    7.https://typecodes.com/web/centos7yuminstallmysql5.html 初始密码设置

  • 相关阅读:
    《Java程序设计》终极不改版【下】
    《Java程序设计》终极不改版【下】
    !终端伪装测试之fuck校园网
    !终端伪装测试之fuck校园网
    关于js中单双引号以及转义符的理解
    关于js中单双引号以及转义符的理解
    关于js中单双引号以及转义符的理解
    正则表达式【第二卷】
    正则表达式【第二卷】
    正则表达式【第二卷】
  • 原文地址:https://www.cnblogs.com/ikel/p/8143996.html
Copyright © 2011-2022 走看看