Forum Moderators: coopster

Message Too Old, No Replies

Its not php its MySql,

but they go hand in hand

         

humpingdan

5:05 pm on Feb 20, 2004 (gmt 0)

10+ Year Member



I was just wondering if anybody has any links to Mysql forums, im currently in the process of learning it but need a little help!

coopster

5:09 pm on Feb 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What are you stuck on? Go ahead and post your question. The moderator will move it if necessary.

humpingdan

9:10 am on Feb 23, 2004 (gmt 0)

10+ Year Member



im trying to install mysql on my ibook, Mac os X, i run the server and that seems to go fine, i can get into mysql so i get mysql> in the terminal window but as soon as i do create database new; you do not have root access please read manual on security?

any pointers?

coopster

3:28 pm on Feb 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes. After you get MySQL up and running, you have a couple of post-installation steps left regarding security. I usually do three things, minimum:
  1. Change the root password.
  2. Remove the anonymous-user account that has all privileges.
  3. Setup new user(s).

MySQL currently has a two default databases,

test
and
mysql
. The former is fairly obvious, a test database that you can play around in. The latter is how mysql implements security -- they use their own database. Log in as
root
and you can look around --
  • USE mysql;
  • SHOW TABLES;
  • SELECT * FROM user;
  • SELECT * FROM db;

You can also DESCRIBE the tables to see the columns involved and when you read through the GRANT and REVOKE syntax and parameters, things will start coming together.

Resources you may want to review:
Windows Post-installation Procedures [mysql.com]
GRANT and REVOKE Syntax [mysql.com]

webadept

3:39 pm on Feb 23, 2004 (gmt 0)

10+ Year Member



yeah, you have to set the root password before you can use MySQL. And then, if you are not root, when loging in, you have to have the CREATE permision given to you from root, in order to create a datatable or database.

If you already setup root right, login to mysql and create the database you want.

create database 'testmebase';

now you have the database, you need to give your user account permision to work with it. It still doesn't have any tables or anything like that, it is just a base. So now you want to run a query like

grant all on testmebase.* to mehere@localhost identified by "myfavpasswd";

That is if you aren't worried about security right now. During development security isn't that much of an issue; things get tighten later.

Anyway, you should be able to log off as root now, and log in as your user, and use that database to create tables, drop tables and basically run-amook.

Now remember that login accounts for your MySQL database and your OS are different, and don't intermix. So, you don't have to be signed in as root, to log onto MySQL as root, you just have to have the password. This is why it's always a good idea to use the @localhost part when giving permissions to a user. What that means is they have to be on that computer, not logging in remotly. Any time you create an account to use with PHP, always use @localhost.

Also, if you have two databases, on the same server, and you use one password for the first, then change the password for the second, you will find that you can't log into the first one. You only have one MySQL account per server, no matter how many databases you have there. That is not to say that a user on the OS can't have 100 MySQL accounts on the same serer (and we frequently do).

After you set the permissions, you may have to use mysqladmin to refresh the tables and get your password validated.

mysqladmin -u root -p flush-privileges

Now if you haven't setup your root password yet, then go to this page, read it over and follow the directions.

www.ejbsolutions.com/products/obox/community/ch11.html

or better

[mysql.com...]

and

[mysql.com...]

good luck

Glenn Hefley

[edited by: jatar_k at 5:31 pm (utc) on Feb. 23, 2004]
[edit reason] delinked [/edit]

humpingdan

9:39 am on Feb 24, 2004 (gmt 0)

10+ Year Member



many thanks.

for some reason now when i try to sudo chown -R i get an invald argument error! oh joy!