zoukankan      html  css  js  c++  java
  • linux安装数据库mysql

    1
    rpm -qa | grep -i mysql
    2 卸载已有的mysql库包
    rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
    
    3用rpm方式安装mysql的server端 (man rpm 查看-ivh的具体意思)
    rpm -ivh ./MySQL-server-5.5.47-1.linux2.6.x86_64.rpm
    4用rpm方式安装mysql的client端
    rpm -ivh ./MySQL-client-5.5.47-1.linux2.6.x86_64.rpm
    5
    
    service mysql status
    
    6
    service mysql start
    
    7
    mysql -uroot
    8 设置数据库的root账户密码
    update mysql.user set password=PASSWORD('root') where User ='root';
    9 打开远程访问连接(等于授权)
    update mysql.user set host='%' where user='root' and host = '127.0.0.1';
    10 刷新授权
    flush privileges;
    
    二、rpc在centos下安装的mysql的乱码问题:
    
    1、安装mysql之后默认的字符编码为latin1
    
    登录mysql之后可以通过 show variables like '%char%'查看,显示如下
    
    +----------------------+---------------------
    | Variable_name | Value
    +-----------------------+---------------------
    | character_set_client | latin1
    | character_set_connection | latin1
    | character_set_database | latin1
    | character_set_filesystem | binary
    | character_set_results | latin1
    | character_set_server | latin1
    | character_set_system | utf8
    | character_sets_dir | /usr/share/mysql/charsets/
    +---------------------+----------------------
    
    2、进入/usr/share/mysql目录之后,拷贝my-medium.cnf 到/etc下
    
    [root@linuxidc mysql]# cp my-medium.cnf /etc/my.cnf
    
    编辑my.cnf
    
    [root@linuxidc mysql]# vim my.cnf
    
    在最后添加:
    
    [client]
    #password       = your_password
    port            = 3306
    #++++++++++++++++++++++++++++++++
    default-character-set=utf8
    #++++++++++++++++++++++++++++++++
    socket          = /var/lib/mysql/mysql.sock
    
    [mysqld]
    port            = 3306
    socket          = /var/lib/mysql/mysql.sock
    #++++++++++++++++++++++++++++++++
    character-set-server=utf8
    character-set-client=utf8
    collation-server=utf8_general_ci
    #++++++++++++++++++++++++++++++++
    skip-external-locking
    
    [mysql]
    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates
    #++++++++++++++++++++++++++++++++
    default-character-set=utf8
    #++++++++++++++++++++++++++++++++
    
    保存退出。
    
    3、重启mysql服务
    
    [root@linuxidc mysql]# /etc/init.d/mysql restart
    
    4、登录mysql之后 再次通过show variables like '%char%'查看,显示如下
    
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client    | utf8                      |
    | character_set_connection | utf8                      |
    | character_set_database  | latin1                    |
    | character_set_filesystem | binary                    |
    | character_set_results    | utf8                      |
    | character_set_server    | utf8                      |
    | character_set_system    | utf8                      |
    | character_sets_dir      | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    
    OK 解决完毕!!
    
    
    三、卸载rpm安装的mysql:
    whereis mysql (查找mysql的所有安装目录)
    which mysql   (查看mysql的运行文件所在位置)
    
    将mysql安装到指定目录:
    比如安装xxx.rpm包,以relocate 参数进行安装,安装到/opt/temp目录:
    rpm -ivh --relocate=/opt/temp xxx.rpm;
    以prefix进行安装:
    rpm -ivh --prefix= /opt/temp  xxx.rpm
    
    
    create database yun;
    
    CREATE TABLE `USER` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `userName` varchar(25) DEFAULT NULL,
      `password` varchar(25) DEFAULT NULL,
      `registerdata` datetime DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    
    CREATE TABLE User(
    id INT(11) NOT NULL AUTO_INCREMENT,
    username VARCHAR(45) DEFAULT NULL,
    password VARCHAR(15) DEFAULT NULL,
    PRIMARY KEY(id)
    )

     参考:https://blog.csdn.net/weixin_42489073/article/details/81137421

  • 相关阅读:
    模式识别 第一章 概论
    高等代数9 欧几里得空间
    离散数学6 初等数论
    高等代数6 线性空间
    高等代数5 二次型
    GMOJ 6870. 【2020.11.17提高组模拟】ckw的树 (tree)
    1
    Virtual Tree 学习笔记
    [2020.11.14提高组模拟] 鬼渊传说(village)
    企业购置新车,各项费用会计入账以及案例分析
  • 原文地址:https://www.cnblogs.com/JBLi/p/11470828.html
Copyright © 2011-2022 走看看