So this was really something I struggled with and I post this here for myself to remember as much as for the benefit of anyone else.
I'm working on a C project where we decided on using XML files as file "packets" for message parsing. The idea was that XML files would be sent around in a specific format and when the file (message) arrives at the receiving end, the XML file could easily be parsed. The problem I had was getting the libxml2 library to compile.
The following libraries were installed, under Ubuntu linux:
libxml2
libxml2-dbg
libxml2-dev
libxml2-doc
libxml2-utils
After this was done, the /libxml/parser.h file has to be included in the C file, to enable XML parsing. A complete list of functions and lots of info on the XML libraries can be found at http://www.xmlsoft.org/.
The problem was, this still did not compile correctly. For some reason, the compiler recognised the library headers, but not the functions in them. This got me thinking: "Maybe there is some issue with the object code not being found". Lots of Googling later, picking up lots of different bits and pieces from all over the Ubernet, I arrived at a solution.
It was indeed a linking issue, but quite a substantial one. If you're using Eclipse, as I was, add the following info to the Project->Properties section.
Under the Compiler->Directories section, add: /usr/include/libxml2.
Under the linker->libaries->libaries(-l) section, add: xml2.
Under the linker->libaries->search path(-L) section, add: /usr/lib.
That should do it! For all the hard-core makefile people out there, use:
LDFlags="-L/usr/lib -lxml2"
CFLAGS="-I/usr/include/libxml2/"
I hopes this saves someone some trouble! Please reply if you found this helpfull.
Friday, April 3, 2009
Friday, January 9, 2009
MySQL Access denied for @locahost
So my first blog post is an error really near to me. I struggled with it for too long, since, from the instructions I received, it should have been really easy. So what was my problem you ask?
I installed a brand new MySQL database and I have never set one up before. To keep things interesting, this database was installed in Hardy Heron Ubuntu Linux. My application required a new user to be created with a password and some priveliges. This can be very easily done using PHPMyAdmin, also located in the Debian repositories.
After you've installed phpmyadmin, just go to http://localhost/phpmyadmin in your browser. Log in with your root password, this is the password you chose when you installed the MySQL server. It may also be blank, so try that if your having trouble. No go to the privilages section and add a user.
Now we get to my problem, after I had created a user and set its privilages, I could not connect to the database with that user. The important thing to know is that the host of this new user was set to "%". Which is any database, so I thought I would have no problem. I did...
After looking around I saw that many people have this kind of problem and it stems from many different reasons.
See: http://dev.mysql.com/doc/refman/5.1/en/access-denied.html for a complete list of things to look out for. From what I read the magor issues are:
The MySQL server is not running,
the user does not have the correct permissions to access the database,
the Unix environment was not set up correctly (more common in RPM Linux),
Program that use old passwords,
Password not being generated correctly,
and then my error...
Now for all the other fixes, the're solutions are simplish:
Go to phpmyadmin en make sure you've set the privleges for your new user. Check that the boxes are ticked that should be ticked.
If you cannot connect as root, your environment might not have been set up correctly. Run the "mysql_install_db" script. You can get this script by installing the "debian-helper-scripts" package. If you can connect as root, your environment should be OK.
If you using custom programs or programs where you've configured user passwords for them, make sure you didn't change the user password in mysql.
You should not just insert a new password into the mysql/user table. The password must be hashed first. The easiest thing is just to use phpmyadmin for this.
Now my error:
I created a user with host=%. The problem was that when you try to connect with: "mysql -u user-name database-name", that environment looks at what users may access the database. Usually you already have a user installed with name="" and host="localhost". Because the host is more specific than than the user you created's host, mysql will choose this default user. This user, of course does not have access to your database and so you get an access denied message along the lines of: "Access denied for user ''@'localhost' to database 'database-name'".
To fix this, all you have to do, is set your user to have host=host-name. Where do you do this? In phpmyadmin of course. Another option is to remove the ""@localhost user from the system by doing a delete in phpmyadmin.
I hope this fixed your problem or at least gave you and idea of where to start looking for a fix and that you enjoyed my very first blog :-)
I installed a brand new MySQL database and I have never set one up before. To keep things interesting, this database was installed in Hardy Heron Ubuntu Linux. My application required a new user to be created with a password and some priveliges. This can be very easily done using PHPMyAdmin, also located in the Debian repositories.
After you've installed phpmyadmin, just go to http://localhost/phpmyadmin in your browser. Log in with your root password, this is the password you chose when you installed the MySQL server. It may also be blank, so try that if your having trouble. No go to the privilages section and add a user.
Now we get to my problem, after I had created a user and set its privilages, I could not connect to the database with that user. The important thing to know is that the host of this new user was set to "%". Which is any database, so I thought I would have no problem. I did...
After looking around I saw that many people have this kind of problem and it stems from many different reasons.
See: http://dev.mysql.com/doc/refman/5.1/en/access-denied.html for a complete list of things to look out for. From what I read the magor issues are:
The MySQL server is not running,
the user does not have the correct permissions to access the database,
the Unix environment was not set up correctly (more common in RPM Linux),
Program that use old passwords,
Password not being generated correctly,
and then my error...
Now for all the other fixes, the're solutions are simplish:
Go to phpmyadmin en make sure you've set the privleges for your new user. Check that the boxes are ticked that should be ticked.
If you cannot connect as root, your environment might not have been set up correctly. Run the "mysql_install_db" script. You can get this script by installing the "debian-helper-scripts" package. If you can connect as root, your environment should be OK.
If you using custom programs or programs where you've configured user passwords for them, make sure you didn't change the user password in mysql.
You should not just insert a new password into the mysql/user table. The password must be hashed first. The easiest thing is just to use phpmyadmin for this.
Now my error:
I created a user with host=%. The problem was that when you try to connect with: "mysql -u user-name database-name", that environment looks at what users may access the database. Usually you already have a user installed with name="" and host="localhost". Because the host is more specific than than the user you created's host, mysql will choose this default user. This user, of course does not have access to your database and so you get an access denied message along the lines of: "Access denied for user ''@'localhost' to database 'database-name'".
To fix this, all you have to do, is set your user to have host=host-name. Where do you do this? In phpmyadmin of course. Another option is to remove the ""@localhost user from the system by doing a delete in phpmyadmin.
I hope this fixed your problem or at least gave you and idea of where to start looking for a fix and that you enjoyed my very first blog :-)
Subscribe to:
Posts (Atom)