• 学习 Mysql


    1.检查已经安装的mysql信息

    yum list installed mysql*
    rpm -qa | grep mysql*

    2.列出已安装和可安装的mysql信息

    yum list mysql*

    3.安装客户端

    yum install mysql

    4.安装服务器端

    yum install mysql-server

    yum install mysql-devel

    5.数据库字符集设置

    mysql配置文件/etc/my.cnf中加入default-character-set=utf8

    可以使用如下命令查看mysql全局编码格式

    mysql> SHOW VARIABLES LIKE 'character%';
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | utf8 |
    | character_set_filesystem | binary |
    | character_set_results | utf8 |
    | character_set_server | utf8 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (2.05 sec)

    mysql> SHOW VARIABLES LIKE 'collation%';
    +----------------------+-----------------+
    | Variable_name | Value |
    +----------------------+-----------------+
    | collation_connection | utf8_general_ci |
    | collation_database | utf8_general_ci |
    | collation_server | utf8_general_ci |
    +----------------------+-----------------+
    3 rows in set (0.43 sec)


    如果没有成功将编码转成utf-8,也可以使用如下命令进行转.
    mysql> SET character_set_client = utf8 ;
    mysql> SET character_set_connection = utf8 ;
    mysql> SET character_set_database = utf8 ;
    mysql> SET character_set_results = utf8 ;
    mysql> SET character_set_server = utf8 ;

    mysql> SET collation_connection = utf8_general_ci ;
    mysql> SET collation_database = utf8_general_ci ;
    mysql> SET collation_server = utf8_general_ci ;

    6.启动

    service mysqld start或者/etc/init.d/mysqld start

    7.停止

    service mysqld stop

    8.开机启动

    chkconfig --add mysqld

    检查是否成功配置开机启动使用如下命令

    chkconfig --list | grep mysql*

    mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

    9.登录mysql

    mysql -u root -p

    初始默认root无密码

    10.忘记密码

    service mysqld stop

    mysqld_safe --user=root --skip-grant-tables

    mysql -u root

    mysql>use mysql

    mysql>update user set password=password("new_pass") where user="root";

    mysql>flush privileges;

    11.远程访问


    开放防火墙的端口号,默认端口是3306
    mysql增加权限:mysql库中的user表新增一条记录host为"%",user为"root".

    GRANT ALL PRIVILEGES ON * . * TO 'root'@'%' IDENTIFIED BY 'qyf404' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;

    12.Linux MySQL的几个重要目录

    数据库目录 /var/lib/mysql/
    配置文件 /usr/share /mysql(mysql.server命令及配置文件)
    相关命令 /usr/bin(mysqladmin mysqldump等命令)
    启动脚本 /etc/rc.d/init.d/(启动脚本文件mysql的目录)

    作者:辵鵵
    欢迎转载,但未经作者同意请保留此段声明,并在文章页面明显位置给出原文链接。
  • 相关阅读:
    Elasticsearch 从入门到学会之五(索引API-索引属性)
    jenkins 如何发布用java -jar来启动的java项目
    k8s从入门到精通-Pod定义详解
    Docker从入门到精通<9>-docker配置文件以及重启策略
    Docker从入门到精通<8>-docker-compose任务编排
    如何选择Containerd和docker
    Docker从入门到精通-企业级私有仓库harbor
    Docker从入门到精通<7>-docker存储驱动选择
    Docker从入门到精通<6>-使用Dockerfile构建镜像
    Docker从入门到精通<5>-数据持久化
  • 原文地址:https://www.cnblogs.com/qyf404/p/4019032.html
Copyright © 2020-2023  润新知