mysql -uroot -p
status
select version();
select database(); --显示使用的数据库名
select user(); --显示当前的user;
select current_date(); --显示当前日期;
show create table table_name; --显示表定义,同时可以查看表类型
逻辑备份:
mysqldump -uroot -p --all-database >fulldb.sql 全库
mysqldump -uroot -p mysql >mysql.sql 备指定库
恢复:
mysql -uroot -p
重置root密码:
一、
/etc/init.d/mysqld stop 或者 killall -TERM mysqld
mysqld_safe --skip-grant-tables & 或者safe_mysqld --skip-grant-tables &
mysql -u root
update mysql.user set password=PASSWORD('new') where User='root';
flush privileges;
exit
/etc/init.d/mysqld restart
二、
在/etc/my.cnf在[mysqld]配置段添加一行:
skip-grant-tables
/etc/init.d/mysqld restart
update mysql.user set password=PASSWORD('new') where User='root';
flush privileges;
exit
修改/etc/my.cnf的配置,将skip-grant-tables去掉
/etc/init.d/mysqld restart
物理备份:
FLUSH TABLES WITH READ LOCK;
拷贝数据文件
unlock tables;
相关信息查询
[mysql@localhost bin]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.40GHz
stepping : 7
cpu MHz : 2400.140
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 4784.12
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.40GHz
stepping : 7
cpu MHz : 2400.140
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 4797.23
[mysql@localhost bin]$ cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 524476416 485679104 38797312 49152 109215744 268660736
Swap: 1077469184 0 1077469184
MemTotal: 512184 kB
MemFree: 37888 kB
MemShared: 48 kB
Buffers: 106656 kB
Cached: 262364 kB
SwapCached: 0 kB
Active: 4140 kB
Inact_dirty: 362428 kB
Inact_clean: 2500 kB
Inact_target: 131056 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 512184 kB
LowFree: 37888 kB
SwapTotal: 1052216 kB
SwapFree: 1052216 kB
BigPagesFree: 0 kB
[mysql@localhost bin]$ uname -a
Linux localhost.localdomain 2.4.9-e.3smp #1 SMP Fri May 3 16:48:54 EDT 2002 i686 unknown
[mysql@localhost bin]$
[mysql@localhost bin]$ cat /etc/redhat-release
Red Hat Linux Advanced Server release 2.1AS (Pensacola)
[mysql@localhost bin]$ pwd
/usr/local/mysql/bin
[mysql@localhost bin]$ ./mysql -V
./mysql Ver 11.15 Distrib 3.23.44, for pc-linux-gnu (i686)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26078027/viewspace-1052825/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26078027/viewspace-1052825/