Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to use MySQL...

How to use MySQL...
Thread Tools
Jaey
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 2, 2004, 11:20 PM
 
Ugh. It frustrates me. I have mySQL all nice and installed (I think) but I don't know how to use it. Any reccomendations for a beginner's site?
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Feb 2, 2004, 11:25 PM
 
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Jaey  (op)
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 2, 2004, 11:41 PM
 
Hm... Thanks for the site, but now I am getting some errors. When I type 'CREATE DATABSE jokes;' I get "ERROR 1044: Access denied for user '@localhost' to database 'jokes'"

I've tried a couple of other things like opening mysql with "mysql -h localhost root -p" then entering my password. I get the error "ERROR 1045: Access denied for user: 'my_username@localhost' (Using password: YES)"
...and then it doesn't open mysql. Is there something important I'm missing?
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Feb 2, 2004, 11:50 PM
 
OS X runs the mysql daemon as the user 'mysql' and not as your username. assuming you have the path to mysql set in your $PATH, type this in terminal (obviously, you don't type the comments):

# set the admin password to "new_password" <- change this to whatever you want
mysqladmin -u root password new_password

# login to the mysql shell
mysql -h localhost -u root -p

# give the user the right permissions
GRANT ALL PRIVILEGES ON *.* TO mysql@localhost IDENTIFIED BY 'new_password';

that should do the trick and let you create the example from the site.

if you need any more help, ask Simon, or come back in about 4-5 hours. i've got to sleep sometime
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Feb 3, 2004, 12:03 AM
 
Originally posted by Jaey:
Hm... Thanks for the site, but now I am getting some errors. When I type 'CREATE DATABSE jokes;' I get "ERROR 1044: Access denied for user '@localhost' to database 'jokes'"

I've tried a couple of other things like opening mysql with "mysql -h localhost root -p" then entering my password. I get the error "ERROR 1045: Access denied for user: 'my_username@localhost' (Using password: YES)"
...and then it doesn't open mysql. Is there something important I'm missing?
Ooops! Watch that whitespace!

it should be 'mysql -hlocalhost -uroot -p' - Unix/Linux etc is usually pretty picky about whitespace around directives.

In most instances, though, localhost is assumed so unless your MySQL server is on a physically different IP address then you can shorten that to:

'mysql -uroot -p'

As a matter of habit, I'd create an admin user instead of using the root account - just more of a good habit whilst your learning. Being root is a surefire way to really mess something up late at night or to allow security holes.

Get to bed Philzilla. I know you're still reading this.
Computer thez nohhh...
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Feb 3, 2004, 12:13 AM
 
Originally posted by Simon Mundy:
Get to bed Philzilla. I know you're still reading this.
but... i... eh, i'm going.

"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Jaey  (op)
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 3, 2004, 12:55 AM
 
Sweet, thanks for the help guys.

Originally posted by Simon Mundy:
As a matter of habit, I'd create an admin user instead of using the root account - just more of a good habit whilst your learning. Being root is a surefire way to really mess something up late at night or to allow security holes.
Yeah... that's probably a good idea. Erm, how do I do that, though?
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Feb 3, 2004, 08:11 AM
 
Originally posted by Jaey:
Sweet, thanks for the help guys.


Yeah... that's probably a good idea. Erm, how do I do that, though?
Okay... let's call your user 'admin' with the password 'crappassword'

Connect to the MySQL command line with:-

'mysql -uroot -p'

Then type the command

GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , FILE , INDEX , ALTER , CREATE TEMPORARY TABLES ON *.* TO "admin"@ "localhost" IDENTIFIED BY "crappassword" ;



This will give you unrestricted access to all databases and tables, but you can't do anything to the mysql daemon itself (i.e. shut it down, reset it, etc.) whilst you are logged in as that user.

So while this user is safe(r), remember that if someone found out your user/password they could still destroy data or alter the structure of your databases.

Enjoy!
Computer thez nohhh...
     
Jaey  (op)
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 3, 2004, 05:03 PM
 
Thanks for all the help.
     
Truepop
Mac Elite
Join Date: Mar 2003
Status: Offline
Reply With Quote
Feb 4, 2004, 12:39 AM
 
once you get that all squared away and if you installed php, take a look at phpMyAdmin.

http://sourceforge.net/projects/phpmyadmin/
     
mzllr
Registered User
Join Date: Jul 2003
Location: San Jose
Status: Offline
Reply With Quote
Feb 4, 2004, 01:53 AM
 
     
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Feb 4, 2004, 09:37 AM
 
I'm pretty fond of SQLGrinder and use it in my work daily. It supports other databases as well (MySQL, PostgreSQL, Oracle, and Sybase are the ones I use, but it supports numerous others as well).
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 09:39 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,