问题
I study PHP.I'd a XAMPP installation on one of my PC.
I used phpmyadmin for mysql purposes.
But Lately, I installed MYSQL server for a java project purpose.
The problem is that, now I can't access mysql services through phpmyadmin browser
interface.
It shows an error. #2003 MYSQL ERROR.
IS there any way that, I could use these both simultaneously?
Because, I'm used to be familiar with these ?
回答1:
using xampp with another installation of mysql is easy. you need to do 3 things:
1) in xampp/phpadmin/config.inc.php and make the following changes:
- line 21 change the password
- lines 31-32 change the values to a different user (such as the root user listed on 20-21
2) go into xampp/mysql/data and copy the phpmyadmin folder and copy it to the data folder for the other installation (note: by default in windows this is in a hidden folder called program data, so you'll need to turn on view hidden folders in your folder options) so for example, on my drive it's C:/ProgramData/MySQL/MySQL Server 5.5/data. copy the phpmyadmin folder into the data folder. this will put the phpmyadmin tables into your mySQL installation.
3) restart everything
this won't fix everything, but it will allow you to access/edit tables from within the admin panel. a couple of other things need to be copied/tweaked to get it perfect
回答2:
If you want to connect phpmyadmin (mysql) database you must add mysql connector library to your project.
Here is the download link for MySQL Connector/J » 5.1.36
After that you have to give dialect for that library and create java.sql.Connection
interface's object.
So the dialect for mysql and adding connection string like as below and you have to handle SqlException
public static void main(String args[]){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:port_no/db_name","phpmyadmin's username","phpmyadmin's password");
}catch(Exception e){
e.printStackTrace();
}
}
so this is how can you connect the mysql database with your java application
来源:https://stackoverflow.com/questions/13108257/using-xampp-phpmyadmin-while-having-separate-mysql-installation