1、本地连接修改参数。

  a) mysql -h localhost -u root -p,mysql的默认端口为3306,如有修改得话请再加上参数“-P 3306”。

  查看mysql端口的命令:

    mysql> show variables like 'port';

  b) 出现以下错误

    ERROR 1130 (HY000): Host 'UBUNTU' is not allowed to connect to this MySQL server   

>use mysql;
>GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'yourpassword';
>FLUSH PRIVILEGES;

2、远程连接。

  a)# mysql -h 192.168.0.100 -u root -p

     # Enter password:yourpassword

  b) mysql_real_connect(&mysql, "192.168.0.100", "root", "yourpassword", "testDb", 3306, NULL, 0))    

3、如需使用phpmyadmin,还需更改phpmyadmin配置。

  问题:You don't have permission to access /phpmyadmin/index.php on this server.

  wamp+mysql环境:修改"/wamp/alias/phpmyadmin.conf",添加"Allow from all"。

>>Mysql常用命令请猛击 http://www.cppblog.com/zzg/archive/2009/05/29/86066.html

posted on 2013-12-04 09:52  土豆饼  阅读(256)  评论(0编辑  收藏  举报