• ubuntu14.04安装mysql5.6.37


    摘抄这篇文档是为了记录自己的日常学习情况,方便以后查看。后边注明了来源,如有不对的地方,希望大家指正,谢谢!

    首先从mysql官网上下载所需的离线包,我现在的版本是(mysql-5.6.37-linux-glibc2.12-x86_64)。

    下载链接:http://dev.mysql.com/downloads/mysql/

    Select Operating System:  linux-generic,选择(mysql-5.6.37-linux-glibc2.12-x86_64)下载。

    下载完之后,将tar包拷贝到/usr/loacl目录下解压缩:

    tar -xzvf  mysql-5.6.37-linux-glibc2.12-x86_64

    • 重命名为mysql:
      mv  mysql-5.6.37-linux-glibc2.12-x86_64  mysql
    • 在安装之前先升级源文件和安装一个依赖包,mysql运行的时候会用到这个依赖包,否则运行不了:
    • sudo apt-get update
      sudo apt-get upgrade
    • sudo apt-get install libaio-dev
      • 1依赖包安装完之后就该安装mysql了,在/usr/local/mysql目录下运行命令(后同),:(注意输出的文字,里边有修改root密码和启动mysql的命令)
          ./scripts/mysql_install_db --user=root
          Installing MySQL system tables...
          151015 14:11:15 [Note] ./bin/mysqld (mysqld 5.5.45) starting as process 10902 ...
          OK
          Filling help tables...
          151015 14:11:15 [Note] ./bin/mysqld (mysqld 5.5.45) starting as process 10908 ...
          OK
      
          To start mysqld at boot time you have to copy
          support-files/mysql.server to the right place for your system
      
          PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
          To do so, start the server, then issue the following commands:
      
          ./bin/mysqladmin -u root password 'new-password'
          ./bin/mysqladmin -u root -h qiuxiao-ubuntu password 'new-password'
      
          Alternatively you can run:
          ./bin/mysql_secure_installation
      
          which will also give you the option of removing the test
          databases and anonymous user created by default.  This is
          strongly recommended for production servers.
      
          See the manual for more instructions.
      
          You can start the MySQL daemon with:
          cd . ; ./bin/mysqld_safe &
      
          You can test the MySQL daemon with mysql-test-run.pl
          cd ./mysql-test ; perl mysql-test-run.pl
      
          Please report any problems at http://bugs.mysql.com/


      • 启动mysql,指定root用户:
          ./bin/mysqld_safe --user=root &
      • 设置root用户密码
          ./bin/mysqladmin -u root password 'linxiaohui'
      ## 重启mysql:    ./bin/mysqladmin -uroot -p密码 shutdown(注意,u,p后没有空格)    ./bin/mysqld_safe --user=root &
      eg:
      • 重启mysql:
          ./bin/mysqladmin -uroot -plinxiaohuishutdown(注意,u,p后没有空格)
          ./bin/mysqld_safe --user=root &
    • eg1:    root@suepc:/usr/local/mysql/mysql-5.6.37-linux-glibc2.12-x86_64# ./bin/mysqld_safe --user=root &
    • eg2:   root@suepc:/usr/local/mysql/mysql-5.6.37-linux-glibc2.12-x86_64# ./bin/mysql -u root -p
    • 运行eg1和eg2两条命令,成功进入mysql.
      • 设置允许root远程连接: 
        1)本机登陆mysql:

        ./bin/mysql -u root -p

        2)从所有主机:

        mysql> grant all privileges on *.* to root@"%" identified by "root用户的密码" with grant option;

        3)从指定主机:

        mysql> grant all privileges on *.* to root@"192.168.11.205" identified by "root用户的密码" with grant option; flush privileges;
      • 设置字符集: 
        查询字符集:

        mysql> show variables like 'character%';
        • 1

        字符集查询结果

        mysql> SET character_set_database = utf8;
        mysql> SET character_set_server = utf8;
        • 1
        • 2

        重启,使字符集生效

      • 设置开机启动 
        可以通过support-files下的mysql.server启动停止mysql,命令如下: 
        启动mysql:./support-files/mysql.server start –user=root 
        停止mysql:./support-files/mysql.server stop

        1)mysql启动默认使用的是/etc/my.cnf配置文件,所以拷贝一份配置文件到/etc/下:

        cp ./support-files/my-medium.cnf /etc/my.cnf
        • 1

        2)拷贝mysql.server文件到/etc/init.d/目录下:

        cp ./support-files/mysql.server /etc/init.d/mysql.server
        • 1

        3)指定启动时所使用的用户,修改my.cnf配置文件,在[mysqld]下加一行user=root:

        vim /etc/my.cnf
        • 1

        编辑my.cnf文件,增加启动用户
        4)设置开机启动:

        update-rc.d -f mysql.server defaults
        • 1

        设置开机启动

      至此,mysql安装完毕,重启Ubuntu,验证一下mysql是否已经随机启动 
      重启Ubuntu

      Navicat连接mysql 
      Navicat连接mysql

      连接成功

      由图可知,连接成功! 

    参考出处:http://blog.csdn.net/qiuxiao630320/article/details/49150585


  • 相关阅读:
    CDI Features
    Java Design Patterns
    pyautogui
    TCP/UDP的套接字Socket通信工作流程
    TCP连接的建立与释放(三次握手、四次挥手)
    python实现单例模式的三种方式及相关知识解释
    面向对象的三个基本特征
    网络编程
    初识python
    目录
  • 原文地址:https://www.cnblogs.com/suesky/p/7647873.html
Copyright © 2020-2023  润新知