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 初始密码设置

  • 相关阅读:
    C语言:计算并输出S=1+(1+2^0.5)+(1+2^0.5+3^0.5)...+(1+2^0.5+3^0.5+...+n^0.5)
    C语言:计算输出给定数组中每相邻两个元素的平均值的平方根之和。
    C语言:把分数最低的学生数据放入数组b所指的数组中,-从键盘输入若干字符串,写入文件myfile4中,用-1作字符输入结束的标志,
    C语言:根据形参c中指定的英文字母,按顺序打印出若干后继相邻字母,-主函数中放入一个带头节点的链表结构中,h指向链表的头节点。fun函数找出学生的最高分-使用插入排序法对字符串中的字符进行升序排序。-从文件中找到指定学号的学生数据,读入次学生数据,
    C语言:将形参s所指字符串中所有ASCII码值小于97的字符存入形参t所指字符数组中,
    负载测试、压力测试和性能测试的区别
    一个有广告的纸杯子的测试用例设计(黑盒测试用例设计)
    java中Comparator的用法
    java 判断字符串中 大小写字母 数字和其他字符个数方法
    java Socket和ServerSocket多线程编程
  • 原文地址:https://www.cnblogs.com/ikel/p/8143996.html
Copyright © 2011-2022 走看看