mysql时间戳转换
数字转时间:
select FROM_UNIXTIME(1418691195721/1000);
时间转数字:
select UNIX_TIMESTAMP('2014-12-18 23:23:23');
安装mysql
- 是否安装过
yum list installed mysql*
rpm -qa|grep mysql*
- 是否有包
yum list mysql*
- 安装客户端
yum install mysql
- 安装服务端
yum install mysql-server
yum install mysql-devel
- 字符集设置
cd /etc/my.cnf
vi 添加 default-character-set=utf8
- 开机启动
chkconfig --add mysqld
chkconfig mysqld on
chkconfig --list|grep mysql*
- 启动服务
service mysqld start
/etc/init.d/mysqld start
- 关闭服务
service mysqld stop
- 创建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
- 增加权限
user表 host=% user=root
- mysql重要目录
/var/lib/mysql/ 数据库目录
/usr/share/mysql 配置文件(命令以及配置文件)
/usr/bin 命令
/etc/rc.d/init.d/ 启动脚本文件mysql的目录
- 让mysql数据库更安全
mysql -u root -p123456
drop database test;//删除TEST数据库
delete from mysql.user where user="";//删除匿名账户
flush privileges;//重载权限
- mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
- 初始参数 my.cnf
[mysqld]
default-character-set=utf8
default-storage-engine=INNODB
[client]
default-character-set=utf8
- 配置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";
- 远程访问失败
service iptables stop//关闭防火墙
grant all privileges on *.* to root@'%' with grant option;//赋予任何远程主机使用root访问的权限
网友评论