Mysql常用使用技巧

    1.为petition_mz用户授予visit_mz数据库的所有权限 反倒所发生的

GRANT ALL PRIVILEGES ON visit_mz.* TO petition_mz@'%' IDENTIFIED BY 'petition_mz';

    2.查询本周第一天

select DATE_ADD(CURDATE(),INTERVAL -WEEKDAY(CURDATE()) DAY);

    3.查询本月第一天

select DATE_ADD(curdate(),interval -day(curdate())+1 day);

    4.安装Linux版本的MySQL,发生如下问题:

       Starting MySQL...The server quit without updating PID file (/var/lib/mysql/centos6.3.pid).                                                          [FAILED]

       解决办法:在/etc/my.cnf下添加,datadir = /usr/local/mysql/data

      ----

       ./bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

      解决办法:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

你可能感兴趣的:(Mysql常用使用技巧)