zoukankan      html  css  js  c++  java
  • Linux系统安装MySQL步骤及支持远程操作配置方法

    一、数据库安装(安装在/usr/local目录)

    1. 压缩包拷贝到/users/lengyufang/tools

    2. groupadd mysql
    3. useradd -r -g mysql -s /bin/false mysql
    4. cd /usr/local
    5. tar zxvf /users/lengyufang/tools/mysql-5.5.48-linux2.6-x86_64.tar.gz
    6. ln -s mysql-5.5.48-linux2.6-x86_64 mysql
    7. cd mysql
    8. chown -R mysql .
    9. chgrp -R mysql .
    10. scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    11. chown -R root .
    12. chown -R mysql data
    13. cp support-files/my-medium.cnf /etc/my.cnf
    14. bin/mysqld_safe --user=mysql1 &
    15. ln -s /usr/local/mysql/bin/mysql /usr/bin
    ln -s /usr/local/mysql-5.5.48-linux2.6-x86_64/bin/mysqladmin /usr/bin

    以下步骤安装在 /users/mysql目录

    2. groupadd mysql
    3. useradd -r -g mysql -s /bin/false mysql
    4. cd /users/mysql
    5. tar zxvf /users/lengyufang/tools/mysql-5.5.48-linux2.6-x86_64.tar.gz
    6. ln -s mysql-5.5.48-linux2.6-x86_64 mysql
    7. cd mysql
    8. chown -R mysql .
    9. chgrp -R mysql .
    10. scripts/mysql_install_db --user=mysql --basedir=/users/mysql/mysql --datadir=/users/mysql/mysql/data
    11. chown -R root .
    12. chown -R mysql data
    13. cp support-files/my-medium.cnf /etc/my.cnf
    14. bin/mysqld_safe --user=mysql &
    15. ln -s /users/mysql/mysql/bin/mysql /usr/bin
    ln -s /users/mysql/mysql-5.5.48-linux2.6-x86_64/bin/mysqladmin /usr/bin

    二、设置数据库登陆密码

    默认安装后,登陆mysql不用密码

    [zhangqi@A10122901 ~]$ mysql
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.5.48-log MySQL Community Server (GPL)

    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    This software comes with ABSOLUTELY NO WARRANTY. This is free software,
    and you are welcome to modify and redistribute it under the GPL v2 license

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

    mysql> 

    为了保证安全,设置mysql登陆密码的重要性不言而喻。方法如下:

    shell下执行:


    /usr/bin/mysqladmin -u root password 123456 #密码是123456

    [root@test1 local]# mysql
        ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
        显示错误,说明密码已经修改。

    三、数据库支持远程访问设置
    1、mysql -u root -p
       然后输入密码

    2、use mysql;

    3、grant all privileges on *.* to root@"%" identified by "123456";

    四、远程访问数据库

    mysql -h 10.43.114.4 -u root -p 123456 db_code_cover -e "select * from tbl_code_cover"

    #db_code_cover是数据库名,tbl_code_cover是db_code_cover下的数据表

    注意,以上语法是在shell下执行mysql语句的方法。

    熟悉mysql的人都知道,select * from tbl_code_cover是标准的mysql环境下的执行语句。


    五、查看数据库数据的存放目录

    1、mysql -u root -p
       然后输入密码

    2、show variables like 'datadir%';

       MySQL [db_code_cover]> show variables like 'datadir%';
    +---------------+--------------------------+
    | Variable_name | Value                    |
    +---------------+--------------------------+
    | datadir       | /users/mysql/mysql/data/ |
    +---------------+--------------------------+

    1 row in set (0.00 sec)

    value值表明数据文件的位置是/users/mysql/mysql/data/

    注意,步骤一中的第10步 scripts/mysql_install_db --user=mysql --basedir=/users/mysql/mysql --datadir=/users/mysql/mysql/data

    会指定数据库文件位置。

  • 相关阅读:
    任务45:Identity MVC:注册逻辑实现
    任务44:Identity MVC: EF + Identity实现
    Identity MVC:UI
    任务42:EF Core Migration
    任务41:Individual authentication 模板
    任务40:介绍
    任务39:Role以及Claims授权
    postman中 form-data、x-www-form-urlencoded、raw、binary的区别
    任务38:JWT 设计解析及定制
    任务37:生成 JWT Token
  • 原文地址:https://www.cnblogs.com/onetwo/p/5435790.html
Copyright © 2011-2022 走看看