• linux下的mysql安装


    1、下载安装包
    http://dev.mysql.com/downloads/mysql/#downloads
    推荐下载通用安装方法的TAR包(http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar)。
    2.看看自己安装过mysql;安装过则删除
    [root@localhost Desktop]$ rpm -qa | grep mysql
    mysql-libs-5.1.52-1.el6_0.1.x86_64
    [root@localhost ~]# rpm -e mysql-libs-5.1.52.x86_64 --nodeps
    [root@localhost ~]# 

    3.创建mysql用户及组

    [root@localhost ~]#groupadd mysql
    [root@localhost ~]#useradd -r -g mysql mysql

    之后可以查看一下成功创建没

    [root@localhost ~]# cat /etc/group | grep mysql
    [root@localhost ~]# cat /etc/passwd | grep mysql4.
    4.将tar.gz解压到所要安装的目录
    当然首先将mysql的。tar.gz包拖到对应的目录,使用winscp工具
     
    [root@promote local]# tar -zxvf mysql-5.7.15-linux-glibc2.5-i686.tar.gz

    5. 解压成功后将文件改个名字

    [root@promote local]# mv mysql-5.7.15-linux-glibc2.5-i686 mysql

    6.安装和初始化数据库

    [root@promote local]# mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
    [root@promote local]# cd mysql
    [root@promote local]#
    ----------------------
    如果改变默认安装路径,则需要
    1)/etc/my.cnf、/etc/init.d/mysqld中修改
    basedir='/apps/mysql'
    datadir='/apps/mysql/data'
    2)创建ln
    mkdir -p /usr/local/mysql/bin
    ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld
    ----------------------
    [root@promote mysql]#cp -a ./support-files/my-default.cnf /etc/my.cnf

     问你是否覆盖时,yes

    [root@promote local]#cp -a ./support-files/mysql.server  /etc/init.d/mysqld
    [root@localhost mysql]# cd bin/
    [root@localhost bin]# ./mysqld_safe --user=mysql &
    [1] 1986
    [root@promote bin]# 2016-10-05T16:34:17.548875Z mysqld_safe Logging to '/usr/local/mysql/data/promote.cache-dns.local.err'.
    2016-10-05T16:34:17.629041Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data


    [root@promote bin]#  /etc/init.d/mysqld restart
    Shutting down MySQL..2016-10-05T16:35:37.679390Z mysqld_safe mysqld from pid file /usr/local/mysql/data/promote.cache-dns.local.pid ended
                                                               [  OK  ]
    Starting MySQL.                                            [  OK  ]
    [1]+  Done                    ./mysqld_safe --user=mysql
    [root@promote bin]# 

     设置开机启动mysql

    [root@localhost bin]# chkconfig --level 35 mysqld on

    7.初始化密码
    mysql5.7会生成一个初始密码,用来登陆的
    [root@localhost bin]# cat /root/.mysql_secret
    # Password set for user 'root@localhost' at 2016-10-06 00:29:51
    Lfu+t9hi+ojn
    [root@promote bin]# ./mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.15

    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

    修改密码
    mysql> SET PASSWORD = PASSWORD('123456');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

     8.添加远程访问权限

    mysql> use mysql; 
    mysql> update user set host = '%' where user = 'root';
    mysql>quit
    [root@promote bin]# /etc/init.d/mysqld restart

     9.开放端口3306(也可以用其他端口)


    [root@localhost bin]#/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT;
    [root@localhost bin]#/etc/init.d/iptables status
    [root@localhost bin]#/etc/rc.d/init.d/iptables save
     
    我真的很想把我写的代码与你分享
  • 相关阅读:
    服务器&域名那些事儿
    原生js实现简单打字机效果
    Mac OS X 11以上系统的Rootless机制问题
    用hexo书写github.io博客 学习心得 教程
    冒泡排序
    选择排序
    TCP三次握手和四次挥手
    常见HTTP状态码
    JSONP
    前端缓存(cookies、localStorage、sessionStorage)
  • 原文地址:https://www.cnblogs.com/zhazhenyu1992/p/5932498.html
Copyright © 2020-2023  润新知