我在使用Squirrel SQL客户端连接MySQL时遇到了问题。我之前成功连接过Oracle和Derby,但这一次似乎出了些问题。
我按照以下步骤在我的Mac上安装了MySQL:
To install MySQL:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" brew install git brew update brew install mysql
To secure the installation:
mysql.server start mysql_secure_installation mysql.server stop
To create a new database:
mysql.server start mysql -uroot -pmypassord create database mydb; show databases;
To know where databases are stored:
mysql.server start mysql -uroot -pmypassword SELECT @@datadir, @@innodb_data_home_dir
To create a table
use mydb; create table tblemployee ( employeeID int not null, firstname varchar(50), lastname varchar(50), titleID int, salary float, primary key (employeeID) );
在我按照以下步骤后:
- MySQL已经安装在 /usr/local/Cellar/mysql/5.6.17 目录下
- 数据库存储在 /usr/local/var/mysql/mydb 目录下
- tblemployee 表已经成功创建。
接下来,在SQuirreL中,我安装了MySQL的驱动程序(mysql-connector-java-5.1.30-bin),并创建了一个别名,其中URL为 "jdbc:mysql:/usr/local/var/mysql/mydb",用户名为 "root" ,密码为 "mypassword"。
但是当我尝试连接时,我会收到以下错误消息:
打开 SQL 连接时发生意外错误。
当我点击 Stack Trace 时,我会得到以下信息:
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.sql.SQLException: Unable to create connection. Check your URL.
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:202)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: java.sql.SQLException: Unable to create connection. Check your URL.
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(Unknown Source)
... 5 more
Caused by: java.sql.SQLException: Unable to create connection. Check your URL.
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(Unknown Source)
... 8 more
我做错了什么?