• 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

  • 相关阅读:
    韩日网民爆发网络大战 互相攻瘫服务器 狼人:
    2010年RSA大会RSA总裁主题演讲:云的安全 狼人:
    黑客非法下载4千万条学历数据被判刑 狼人:
    黑客称Windows 7比Linux安全 Flash是威胁 狼人:
    方法代码Scala中的语言特性是如何实现的(2)
    参考知识svideo vs. composite video vs. component video 几种视频格式详细说明和比较
    旋转长度左旋转字符串(26)
    设置参数cocos2dx 2.x 进度条CCProgressTimer
    队列输入队列基本操作
    安装华硕华硕电脑K52JU安装银联控件蓝屏
  • 原文地址:https://www.cnblogs.com/JBLi/p/11470828.html
Copyright © 2020-2023  润新知