View Full Version : mysql user
29th January 2007, 03:32 AM
I'm relatively knew to mysql. I was just wondering if i could get a little bit of help on the commands and such.
mysql> GRANT ALL PRIVILEGES ON 'database'.* TO 'web_user'@'localhost' IDENTIFIED BY 'thepassword';
what is the localhost? It sounds like a dumb question but i'm not exactly sure what to put there. Also i've been running this command using the url as local host and its been giving me an error saying
"Table 'mysql.user' doesn't exit"
What does this mean...I was under the impression that GRANT created a new user
Thankyou in advance for any help
29th January 2007, 04:31 AM
localhost is the name of your machine. I think GRANT creates the user in msql.user table.
If you have an error or do not see the mysql.user, I tink you have problems with mysql instalation.
29th January 2007, 04:38 AM
Your computer has two kinds of personalities...localhost is the default built in name for the machine, akin to you referring to yourself as "me", instead of by name ("scottp009"). :D
Now, when you set up your machine and its network interface card to communicate with other machines, you'd want to give it an IP address and "hostname", as it wouldn't make much sense to refer to itself as "me" on the network, since other machines know themselves as "me" (localhost) as well. :p
"Localhost" would also be tied to the loopback interface 127.0.0.1 on the machine...so communicating with the mysql daemon (service) locally, you are effectively talking to "localhost". You could envision this as thinking in your head, rather than communicating to others. This is called interprocess communications via a unix socket. Services/daemons
communicate via an IP address and a port (TCP/UDP), and on the local host it would be
IP 127.0.0.1: Port 3306 in the case of mysql.
Run the query "add new user to mysql" through google and you will get a bunch of answer.
Do read, it cannot be avoided.
29th January 2007, 04:59 AM
I did a bit of reading before I posted, mostly off the mysql homepage.
I tried to add a user by doing:
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
However when I write that command I get the same error, mysql.user doesn't exist.
When I type show databases I don't have a database called mysql.user but why is it looking to that table. I created another table and typed use nameoftable so I thought it would look to that.
thanks to both of you guys for the responses so far they've been a big help and thanks in advance to anything else you can tell me!
29th January 2007, 05:11 AM
Your database was not installed correctly. mysql.user refers to a table named "user" in a database (you should call it a schema, not a database, it's more accurate) called 'mysql'. You should, by default, have mysql and information_schema listed when you "show databases"
29th January 2007, 05:13 AM
ahh man...ok I think I actually may have deleted it by my own stupidity. I installed using yum and i'm pretty sure it was there and I deleted it myself. Is there anyway to add it back in or update or something using yum? Thanks a lot
29th January 2007, 05:16 AM
Here are a couple of helpful sites:
29th January 2007, 05:19 AM
Thanks a lot for the sites...I used a site which looks almost identical to the first one on the list.
29th January 2007, 05:30 AM
If you think you deleted it, just reinstall. Remove the mysql-server rpm, then clean out anything that may be left behind in /var/lib/mysql, finally reinstall via yum. There's actually a script to create the default schema, but reinstalling would probably be easier based on your level of experience.
29th January 2007, 05:43 AM
Just remember, after a fresh install, the default user for mysql is root, but no password has been set, so you can connect with:
[root@localhost ~]# mysql -u root
once you are at the prompt
set the mysql password for root. This does not have to be the same as roots system password, it's actually better not to use the same system password. Remember to use the colon ; to end mysql statements. (Statements entered at the >mysql prompt)
The next time you log on as root, you need to use the -p switch as well:
[root@localhost ~]# mysql -u root -p
You will be promted for roots mysql password. You could enter the password after the -p switch, but it would be in clear text
29th January 2007, 05:55 AM
Some basic commands:
>mysql show databases;
shows the databases...only the defaults in the beginning, "mysql" and "test".
>mysql use databasename;
which selects the database you want to work with.
>mysql show tables;
shows the tables of the selected database.
>mysql describe "tablename";
shows the field values of the colums of the table of interest.
>mysql show help;
You'll get there, no worries. :eek:
29th January 2007, 06:52 AM
Thankyou sooo much...you guys have been a huge help! I know it must be frustrating working with such a newb like me. I really appreciate your help and i'm going to try to reinstall mysql and do it right this time!
29th January 2007, 07:09 AM
You clearly stated your problem, showing examples and error messages, read the replies, tried the suggestions and provided feedback when requested. It was a good question to start with, I wish all the "newbies" on this forum would take a lesson from you. :-)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.