mysql数据库常用命令
登陆数据库
$mysql –u user –p
退出数据库
$exit
查看数据库
$show DATABASES;
查看表格
$show TABLES;
sql教程
http://www.w3school.com.cn/sql/index.asp
mysql数据库GUI工具
我就用过以下两种,感觉都挺好用的。
1、phpmyadmin
php开发的一个网页版工具,可通过web管理mysql数据库。
安装步骤apache->php->phpmyadmin
2、Navicat for mysql
Windows桌面程序。Navicat还有可以支持各种数据库类型的版本。
http://www.cr173.com/soft/38153.html
注意:数据库默认只能localhost连接。远程连接时需要数据库授权,否则报错“1130-host ... is not allowed to connect to thisMySql server”。
1、允许root使用密码123456从任何主机连接到mysql服务器
$grantall all privileges on *.* to ‘root’@’%’ identified by ‘123456’ with grantoption;
$flush privileges;
2、允许root从xxx.xxx.xxx.xxx主机连接到mysql服务器,密码为123456
$grantall privileges on *.* to ‘root’@’xxx.xxx.xxx.xxx’ identified by ‘123456’ withgrant option;
$flushprivileges;
3、允许root从xxx.xxx.xxx.xxx主机连接到mysql服务器的testdb数据库,密码为123456
$grantall privileges on testdb.* to ‘root’@’xxx.xxx.xxx.xxx’ identified by ‘123456’with grant option;
$flushprivileges;
授权之后远程连接ok,但是本地连接却报错了。。。
授权之后user表里多了一条记录,root多了%的一条记录。
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
解决方法是登陆的时候带上ip。。。,还有一个选项要注意一下skip-name-resolve
$mysql -u root -h 127.0.0.1 -p
参考链接
http://blog.sina.com.cn/s/blog_65915f860101e50c.html