mysql

作者: 你猜_19ca | 来源:发表于2018-08-07 15:21 被阅读0次

    mysql时间戳转换

    数字转时间:
    select FROM_UNIXTIME(1418691195721/1000);
    时间转数字:
    select UNIX_TIMESTAMP('2014-12-18 23:23:23');

    安装mysql

    1. 是否安装过
    yum list installed mysql*
    rpm -qa|grep mysql* 
    
    1. 是否有包
    yum list mysql*
    
    1. 安装客户端
    yum install mysql
    
    1. 安装服务端
    yum install mysql-server
    yum install mysql-devel
    
    1. 字符集设置
    cd /etc/my.cnf
    vi 添加 default-character-set=utf8
    
    1. 开机启动
    chkconfig --add mysqld
    chkconfig mysqld on
    chkconfig --list|grep mysql*
    
    1. 启动服务
    service mysqld start
    /etc/init.d/mysqld start
    
    1. 关闭服务
      service mysqld stop
    2. 创建root
    mysqladmin -u root password zab123456
    mysql -u root -pzab123456
    

    [忘记密码]

    service mysqld stop
    mysqld_safe --user=root --skip-grant-tables
    mysql -u root
    use mysql
    update user set password=password("new_pass")where user="root";
    flush privileges
    
    1. 增加权限
      user表 host=% user=root
    2. mysql重要目录
    /var/lib/mysql/ 数据库目录
    /usr/share/mysql 配置文件(命令以及配置文件)
    /usr/bin 命令
    /etc/rc.d/init.d/ 启动脚本文件mysql的目录
    
    1. 让mysql数据库更安全
    mysql -u root -p123456
    drop database test;//删除TEST数据库
    delete from mysql.user where user="";//删除匿名账户
    flush privileges;//重载权限
    
    1. mysql扩展
    yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
    
    1. 初始参数 my.cnf
    [mysqld]
    default-character-set=utf8
    default-storage-engine=INNODB
    [client]
    default-character-set=utf8
    
    1. 配置ODBC
      添加mysql驱动 vi /etc/odbcinst.ini
    [MySQL]
    Description     = ODBC for MySQL
    Driver          = /usr/lib/libmyodbc3.so
    Setup           = /usr/lib/libodbcmyS.so
    FileUsage       = 1
    添加DSN vi /etc/odbc.ini
    [ibp]
    Driver=MySQL
    Server=127.0.0.1
    PORT=3306
    DATABASE=ibp
    OPTION=3
    CHARSET=UTF8
    测试ODBC连接
    isql -v ibp root 123456;
    quit;
    修改数据库的配置文件
    > vi /etc/my.cnf 
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1
    default-character-set=utf8
    lower_case_table_names=1
    max_allowed_packet=16M
    # Disabling symbolic-links is recommended to prevent assorted security risks;
    # to do so, uncomment this line:
    # symbolic-links=0
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    default-character-set=utf8
    16)MYSQL常用命令
    mysql -u root -p123456
    create database ibp;
    use ibp;
    show tables;
    create table test(name varchar(20));
    describe ibp;
    insert into ibp values("hyq");
    source /usr/local/ibp.sql;
    drop table test;
    delete from test;
    upate test set name="sss" where name="hyq";
    grant all privileges on mydb.* to root@127.0.0.1 identified by "123456";//允许任何 赋予密码
    grant usage on *.* to root@127.0.0.1 identified by "123456";//只允许登录
    grant select on mydb.* to root@127.0.0.1 with grant option;//赋予授权权限
    show grants;
    show grants for root@127.0.0.1;
    revoke all on *.* from root@127.0.0.1;
    create user guest@127.0.0.1 identified by "123456";
    grant select on mydb.* to guest@127.0.0.1;
    drop user guest;
    grant select ,insert, update, delete on mydb.* to guest@"%" identified by "123456";
    
    1. 远程访问失败
    service iptables stop//关闭防火墙
    grant all privileges on *.* to root@'%' with grant option;//赋予任何远程主机使用root访问的权限
    

    相关文章

      网友评论

          本文标题:mysql

          本文链接:https://www.haomeiwen.com/subject/iicavftx.html