LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   A few minor MySQL questions (https://www.linuxquestions.org/questions/linux-software-2/a-few-minor-mysql-questions-64311/)

Bigun 06-08-2003 12:08 AM

A few minor MySQL questions
 
I'm using RH 7.3. I'm a newbie to SQL and reading a book on it. I would like to follow along the examples in the book so I can learn the syntax.

So how do I start the MySQL Server?

How do I log in?

And before I get flamed, is there a good beginners page for MySQL?

Thanks for helping a :newbie: !!

Muddy 06-08-2003 12:13 AM

in RH you can start mysql buy going into /etc/rc.d/init.d and using the "./mysqld start" command as root
you can also go (as root) into /sbin and run ./netsysv and use that to setup mysql to startup @ bootup.

Robert0380 06-08-2003 02:10 AM

it may be best to use safe_mysqld:

as root:

#safe_mysqld &

if you have the default configuration (installed from the rh7.3 cd)
then u log in by doing:

#mysql -uroot

and hit enter. if there is a root password that you set, then it's:

#mysql -uroot -p

and it will prompt you for password information

not sure of a beginners page, maybe just check ont www.mysql.com for docs
and info. If you know SQL then its not hard to figure out what you are doing,
but knowing some of the mysql specific commands is great and make sure
you know about mysqladmin stuff. it should all be on the mysql website.

Bigun 06-08-2003 09:50 AM

Ok, it works, I can now log in. Now how would I password protect certain databases or certain permissions to databases?

Bigun 06-08-2003 04:02 PM

Is anyone here really familiar with setting up MySQL? I looked over the manual pages at MySQL.com and they read like Greek. It's nice that they elaborate what every little option does and all, but I'd like to know how to get it started for now. I just need to understand how to setup permissions to users in MySQL and how to log into it remotely. Would anyone know how to do this?

Robert0380 06-08-2003 05:04 PM

oh the EASIEST way to do this is with webmin

BUT

the hard way (not REALLY hard but takes some patience)
is to add entries to the mysql database

the mysql database is what holds host/user permissions

when you log in to mysql, log in as root and do this to look at the
table:


mysql>\u mysql;

it will say database changed..blah blah

mysql>show tables;

this will show you the tables...

mysql>desc user;

this whill show you the fields in the user table;

and example of how to add a user:

mysql>insert into user(Host, User,.....)
-->values('localhost','usrername'.....);

that's how u would add users..

make sure you encrypt passwords, to do this you can use the
password function

insert into.....(Password)
vaules(password('password'));

that will store the password in an encrypted form.


like i said tho the easiest way is using webmin....webmin lets you
fill in a few fields and click the Add button. it uses a web based interface

http://webmin.com

Bigun 06-09-2003 09:38 AM

Ok, this Webmin thing would seem to be the way to go with a lot of things on Linux....very cool tool. But I think I may have made the situation worse. I went in and added passwords to the root accounts in mysql and now it won't let me have access to the mysql accounts. And yes I am logged in as root.

Suggestions?

Pete Dogg 06-09-2003 10:59 AM

A simple way to create a database and a user is as follows:


mysql --user=root

mysql> CREATE DATABASE mydb;
mysql> GRANT ALL PRIVILEGES ON *.* TO mynewuser@localhost IDENTIFIED BY 'mypassword';


now to specify the privileges you want, you can look up the documentation at mysql.com. Search for GRANT.
In a lot of cases you don't always want to grant all privileges. You may want to grant only select only on one database.
eg)
GRANT SELECT ON mydb.* TO mynewuser@localhost IDENTIFIED BY 'mypassword';

To remove privileges use the REVOKE command.


I think this is the information you are looking for.

Bigun 06-09-2003 11:10 PM

Well, pending recent circumstances, it has deamed beneficial for me to install RH 9 and try it out. If it stinks, I'll go back to RH 7.3. Either way I'll get everything reset. One of the reasons for doing so was because I could not access mysql anymore. Setting the password for the root username under SQL really screwed things up. I tried uninstalling the RPM and re-installing it. It still wouldn't let me in. This coupled with the fact that I couldn't play the latest version of MAME (What can I say, I'm a gaming addict! :)), I will try RH 9.

In the meanwhile I guess I could do some reading on the next part of my learning SQL whilst I wait on the approximately 2 gig download. So my question is this:

I want to use this SQL database with a webpage. So this actually will lead to two questions. How would I make a webpage interact with a SQL database (a web page tutorial for me to read would be fine), and second, what program in Linux would be best to create a webpage that will use the SQL database.

Pete Dogg 06-10-2003 01:35 AM

Most people nowadays use PHP to build a website that can interact with a MySQL (or any) database.

The functions for connecting to MySQL with PHP are here:
http://www.php.net/mysql

I don't know any good tutorials on PHP, hopefully someone else can post that.

You can create php webpages using any text editor. As for what program is the best, I don't know. On windows I like using Dreamweaver. But it's not free.

Bigun 06-10-2003 10:04 AM

Oh, that reminds me, what port does SQL typically communicate through?

Robert0380 06-13-2003 01:01 AM

3306 i think


All times are GMT -5. The time now is 01:34 AM.