第一步:
.安装完
mysql后
[root@sv245 tmp]# mysqladmin -hlocalhost -uroot password '123456'
[root@sv245 tmp]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.41-ndb-7.0.13-cluster-gpl MySQL Cluster Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,password from user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | sv245 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | sv245 | |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> update user set host='%' where host='localhost';
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | % | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | sv245 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | % | |
| | sv245 | |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> exit
Bye
[root@sv245 tmp]# service mysql restart
第二步:
[root@sv245 mysql]# cp my-huge.cnf /etc/my.cnf
[root@sv245 mysql]# vi /etc/my.cnf
在配置文件中增加:
[mysqld]下增加下面一句话:
skip-name-resolve
[root@sv245 mysql]# service mysql restart
ok,可以通过外部工具测试连接了
windows系统下测试如下:
C:\Documents and Settings\lidw>mysql -h 192.168.0.245 -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.1.41-ndb-7.0.13-cluster-gpl-l
og
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
ok,连接成功:
注释:
#1:去掉mysql启动参数中的skip-name-resolve ,然后jdbc连接串用ip地址和主机名均可。
#2:如果保留启动参数skip-name-resolve 的话,在jdbc连接串中只能使用IP地址的方式连接数据库。
--转自