zoukankan      html  css  js  c++  java
  • linux下安装mysql

    1.1. 检测是否已经安装了mysql

    rpm -qa | grep mysql   

    如果已经安装了,将其卸载,如:

    rpm -e --nodeps  mysql-libs-5.1.71-1.el6.x86_64

    1.2. 安装mysql

    1、mkdir /usr/local/src/mysql

    2、cd /usr/local/src/mysql

    3、tar -xvf MySQL-5.6.22-1.el6.i686.rpm-bundle.tar(解压)

    4、安装server
    rpm -ivh MySQL-server-5.6.22-1.el6.i686.rpm
    出错:

    安装依赖:yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6 

     

    需要升级libstdc++-4.4.7-4.el6.x86_64
    yum  update libstdc++-4.4.7-4.el6.x86_64

    5、安装中:

     

    6、安装client

    安装依赖:yum -y install libncurses.so.5 libtinfo.so.5

    7、查询mysq服务运行状态

    服务未启动。

    8、 启动mysql服务
    service mysql start

    9、使用root账号登录mysql
    提示:

    在安装mysql server时有句提示:

    1、 注意:这个密码是不安全的,所有需要修改初始密码。

    2、 使用密码登录mysql账号:mysql -uroot -p

    3、 修改root密码:SET PASSWORD = PASSWORD('123456');

    2.3 系统启动时自动启动mysql服务

    注意:

    centos7开始使得以往老版本系统服务的/etc/init.d的启动脚本的方式就此改变,在centos7中所有对服务的管理都集中到了systemctl当中。
    systemctl是一个系统管理守护进程、工具和库的集合,用于取代以往的System V、service和chkconfig命令。

    创建用于启动MySQL的配置文件
    [root@localhost ~]# touch /usr/lib/systemd/system/mysqld.service
    [root@localhost ~]# cd /usr/lib/systemd/system

    编辑mysqld.service文件,加入如下内容:
    [root@localhost system]# vi mysqld.service
    [Unit]
    Description=MySQL Server
    Documentation=man:mysqld(8)
    Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
    After=network.target
    After=syslog.target

    [Install]
    WantedBy=multi-user.target

    [Service]
    User=mysql
    Group=mysql
    ExecStart=/opt/mysql-5.7.18/bin/mysqld --defaults-file=/etc/my.cnf
    LimitNOFILE = 5000
    保存退出

    备注:ExecStart=/opt/mysql-5.7.18/bin/mysqld (此处请对应修改为MySQL程序所在的路径)
    查找mysqld路径,例如:
    [root@localhost system]# which mysqld
    /opt/mysql-5.7.18/bin/mysqld

    通过systemctl方式启动mysql5.7:
    [root@localhost system]# systemctl start mysqld

    检查MySQL运行状态:
    [root@localhost system]# mysql -p 
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 6
    Server version: 5.7.18-log MySQL Community Server (GPL)

    关闭防火墙:
    [root@localhost system]# systemctl stop firewalld.service
    [root@localhost system]# systemctl disable firewalld.service
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

    设置mysql的开机启动:
    [root@localhost system]# systemctl enable mysqld
    Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
    [root@localhost system]# systemctl list-unit-files | grep mysqld
    mysqld.service                                enabled 

    取消mysql的开机自启动:
    [root@localhost system]# systemctl disable mysqld
    Removed symlink /etc/systemd/system/multi-user.target.wants/mysqld.service.
    [root@localhost system]# systemctl list-unit-files | grep mysqld
    mysqld.service                                disabled

  • 相关阅读:
    C# 二维码 ThoughtWorks.QRCode.dll
    Asp.net生命周期
    进程和线程,多线程等使用方法
    反射的使用与定义
    《委托和事件》
    《泛型集合》
    第三课时《枚举》
    数据库字段包括数组中的每一项
    .NetCore 图片压缩
    NetCore3.0 EF修改
  • 原文地址:https://www.cnblogs.com/lxc116317/p/9588955.html
Copyright © 2011-2022 走看看